首页产品库评测行情新闻|手机数码笔记本台式机DIY硬件数字家庭数码相机办公外设|软件下载游戏开发|社区

更多

数码相机
MP4
LCD
机箱
音箱

天极网 > 开发频道>VB.NET实现Smartphone进程启动

VB.NET实现Smartphone进程启动

2005-03-22 08:21作者:莫艺潜出处:天极网责任编辑:方舟

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

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

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

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

Imports System.Runtime.InteropServices

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

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 Dim tudtShellExecuteInfo As New SHELLEXECUTEINFO
 Dim tstrExecutePath As String
 Dim tudtStartupInfo As STARTUPINFO
 Dim tudtProcessInfo As PROCESS_INFORMATION
 Dim tlngTempa As Int32

 With tudtStartupInfo
  .cb = Marshal.SizeOf(GetType(STARTUPINFO))
 End With

 With tudtShellExecuteInfo
  .cbSize = Marshal.SizeOf(GetType(SHELLEXECUTEINFO))
  .lpFile = clsDAMSMobileMarshal.fnStringToHLocalUni("\windows\calc.exe")
  .lpParameters = IntPtr.Zero '不使用参数,如使用参数可按lpFile的方法申请字符串指针
 End With
 tlngTempa = ShellExecuteEx(tudtShellExecuteInfo) '启动程序

 tudtShellExecuteInfo.Dispose()
 If tlngTempa = 0 Then '使用shellexecuteex失败,试图使用createprocess再打开试试
  tlngTempa = CreateProcess("\windows\calc.exe", "\windows\calc.exe", IntPtr.Zero, IntPtr.Zero, _
0, 0, IntPtr.Zero, IntPtr.Zero, tudtStartupInfo, tudtProcessInfo)
 If tlngTempa <> 0 Then
  Call CloseHandle(tudtProcessInfo.hThread)
  Call CloseHandle(tudtProcessInfo.hProcess)
 End If
End If
End Sub

  以上就是VB.net中启动Smartphone中的应用程序的常规方法,代码在本人的计算机上测试通过,本人的计算机系统配置为WIN2000 高级服务器版+Visual Studio 2003(完全安装)+Smartphone 2003 SDK(开发Smartphone应用程序必备,在微软的网站可以下载,微软提供的免费软件啊!我喜欢8-),网址如下: http://msdn.microsoft.com/mobility/downloads/sdks/default.aspx)。

关注此文的读者还看过:

返回开发频道首页

共2页。 上一页12

软件频道最新更新

热点推荐

天极服务|关于我们|About us|网站律师|RSS订阅|友情合作|加入我们|天极动态|网站地图|意见反馈|MSN/QQ上看天极
Copyright (C) 1999-2012 Yesky.com, All Rights Reserved 版权所有 天极网络