千家信息网

如何利用VB.NET启动Smartphone

发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,这篇文章给大家分享的是有关如何利用VB.NET启动Smartphone的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。下面是一个简单示例,启动手机中的计算器程序,步骤如下:1
千家信息网最后更新 2025年02月01日如何利用VB.NET启动Smartphone

这篇文章给大家分享的是有关如何利用VB.NET启动Smartphone的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

下面是一个简单示例,启动手机中的计算器程序,步骤如下:

1、启动VS.net2003,选Visual Basic 项目,在右边的列表中选智能设备应用程序,在下一个对话框中针对什么平台选Smartphone,类型选Windows应用程序。

2、将上面介绍的辅助类及API声明的代码做成两个模块。

3、为在form1的代码模块顶部加入如下语句:

Imports System.Runtime.InteropServices

4、在 Form1的 load事件中加入启动计算器的代码如下:

  1. Private Sub Form1_Load(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles MyBase.Load

  2. Dim tudtShellExecuteInfo As New SHELLEXECUTEINFO

  3. Dim tstrExecutePath As String

  4. Dim tudtStartupInfo As STARTUPINFO

  5. Dim tudtProcessInfo As PROCESS_INFORMATION

  6. Dim tlngTempa As Int32

  7. With tudtStartupInfo

  8. .cb = Marshal.SizeOf(GetType(STARTUPINFO))

  9. End With

  10. With tudtShellExecuteInfo

  11. .cbSize = Marshal.SizeOf(GetType(SHELLEXECUTEINFO))

  12. .lpFile = clsDAMSMobileMarshal.fnStringToHLocalUni("/windows/calc.exe")

  13. .lpParameters = IntPtr.Zero

  14. '不使用参数,如使用参数可按lpFile的方法申请字符串指针

  15. End With

  16. tlngTempa = ShellExecuteEx(tudtShellExecuteInfo) '启动程序

  17. tudtShellExecuteInfo.Dispose()

  18. If tlngTempa = 0 Then '使用shellexecuteex失败,试图使用createprocess再打开试试

  19. tlngTempa = CreateProcess("/windows/calc.exe", "/windows/calc.exe", IntPtr.Zero,
    IntPtr.Zero, _ 0, 0, IntPtr.Zero, IntPtr.Zero, tudtStartupInfo, tudtProcessInfo)

  20. If tlngTempa <> 0 Then

  21. Call CloseHandle(tudtProcessInfo.hThread)

  22. Call CloseHandle(tudtProcessInfo.hProcess)

  23. End If

  24. End If

  25. End Sub

感谢各位的阅读!关于"如何利用VB.NET启动Smartphone"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

0