VS2008下使用托管代码控制Windows Mobile Device Emulators
2008-10-31 16:07
337 查看
在听黎波老师的Webcast-Visual Studio 2008 移动开发新体验时,听他提到过可以使用代码来控制Device Emulator。今天在msdn上看到了Jim Wilson写的” How To: Programmatically Control the Windows Mobile Device Emulators from .NET”一文,觉得很有必要和大家分享一下。
大家知道,device emulator在调试windows mobile应用程序的时候非常有用。Device Emulator Manager可以执行包括启动device emulator、保存device emulator状态、cradle(和Activesync进行同步)、关闭device emulator等功能。现在我们面临的challenge就是:必须通过Device Emulator Manager的UI,手动控制device emulator。这样就给测试自动化带来了困难。
Device Emulator Manager 和 Device Emulator 3.0是VS2008默认安装的部分,它们引入了Device Emulator Manager API,从而在一定程度上解决了上面的问题。Device Emulator Manager API提供了访问Device Emulator的编程接口,我们可以在desktop应用中调用Device Emulator Manager API,来执行和Device Emulator Manager同样的功能。
l The Device Emulator Manager API
Device Emulator Manager API是通过组件对象模型(COM) In-Process库实现的,即在.NET托管代码中,使用Microsoft.DeviceEmulatorManager.Interop.9.0.dll提供接口。该dll文件位于”%Program Files%\Microsoft Device Emulator\1.0”下,使用API必须添加"Microsoft.DeviceEmulatorManager.Interop"命名空间。同时,为了使用P/F,我们最好加入"System.Runtime.InteropServices"。
l Controlling the Device Emulator
最常用的Device Emulator API就是IDeviceEmulatorManagerVMID接口。下表列出了该Interface的方法和描述。
l A Device Emulator Manager Wrapper
包装(Wrapper)这些API给.NET托管代码来用,可以为许多工程带来方便。示例工程提供的封装包括以下几个类,同时给出了描述:
恩,就啰嗦到这里吧。具体的代码大家可以直接去MSDN上下载,或者通过下面这个链接来获得:http://files.cnblogs.com/dearsj001/DEMAutomationWrapperExample.rar。
Good Luck!
大家知道,device emulator在调试windows mobile应用程序的时候非常有用。Device Emulator Manager可以执行包括启动device emulator、保存device emulator状态、cradle(和Activesync进行同步)、关闭device emulator等功能。现在我们面临的challenge就是:必须通过Device Emulator Manager的UI,手动控制device emulator。这样就给测试自动化带来了困难。
Device Emulator Manager 和 Device Emulator 3.0是VS2008默认安装的部分,它们引入了Device Emulator Manager API,从而在一定程度上解决了上面的问题。Device Emulator Manager API提供了访问Device Emulator的编程接口,我们可以在desktop应用中调用Device Emulator Manager API,来执行和Device Emulator Manager同样的功能。
l The Device Emulator Manager API
Device Emulator Manager API是通过组件对象模型(COM) In-Process库实现的,即在.NET托管代码中,使用Microsoft.DeviceEmulatorManager.Interop.9.0.dll提供接口。该dll文件位于”%Program Files%\Microsoft Device Emulator\1.0”下,使用API必须添加"Microsoft.DeviceEmulatorManager.Interop"命名空间。同时,为了使用P/F,我们最好加入"System.Runtime.InteropServices"。
l Controlling the Device Emulator
最常用的Device Emulator API就是IDeviceEmulatorManagerVMID接口。下表列出了该Interface的方法和描述。
Method | Description |
BringToFront | Moves the Device Emulator to the foreground of the desktop display and makes the Device Emulator the active application. |
ClearSaveState | Clears the Device Emulator's saved state file (.dess). The next time you start the Device Emulator, the Device Emulator will have no existing state and will start from the ROM image. The Device Emulator will therefore appear as a new device. Any software you have installed or setting changes you have made are lost. |
Connect | Starts the Device Emulator. |
Cradle | Puts the Device Emulator in the virtual cradle and causes the Device Emulator to connect to the desktop using Microsoft ActiveSync® (Windows XP) or Windows Mobile Device Center (Windows Vista®). |
get_Name | Returns the display name of the emulator such as Windows Mobile 6 Professional Emulator or Windows Mobile 5.0 Smartphone. The display name is the same value that appears in the Device Emulator Manager user interface's list of Device Emulators. |
get_State | Returns the EMULATOR_STATE enumeration value corresponding to the Device Emulator's current state. Possible values are EMU_NOT_RUNNING, EMU_RUNNING, and EMU_CRADLED. A Device Emulator is in only one state at a time. |
get_VMID | Returns the Device Emulator's Virtual Machine Identifier (VMID), which is a globally unique identifier (GUID) unique to each emulator image. |
GetConfiguration | Returns an XML string describing the Device Emulator's current configuration. |
Reset | Performs a soft-reset or hard-reset of the Device Emulator as specified by the passed integer parameter. A non-zero parameter value specifies a soft-reset. |
SetConfiguration | Sets the Device Emulator to the configuration described in the provided XML string parameter. |
Shutdown | Shuts down the Device Emulator, optionally saving the Device Emulator's state as specified by the passed integer parameter. A non-zero parameter value specifies that the state should be saved. |
UnCradle | Removes the Device Emulator from the virtual cradle and causes the Device Emulator to disconnect from ActiveSync (Windows XP) or Windows Mobile Device Center (Windows Vista). |
包装(Wrapper)这些API给.NET托管代码来用,可以为许多工程带来方便。示例工程提供的封装包括以下几个类,同时给出了描述:
Type | Description |
DeviceEmulatorManagerEx | Represents the Device Emulator Manager. Encapsulates the Device Emulator Manager features of the IDeviceEmulatorManager interface. |
DeviceEmulatorCategory | Represents an individual category. Encapsulates those features of the IDeviceEmulatorManager interface that represent a single category. |
DeviceEmulatorSdk | Represents an individual SDK. Encapsulates those features of the IEnumManagerSDKs interface that represent a single SDK. |
DeviceEmulator | Represents an individual Device Emulator. Provides the same features as the IDeviceEmulatorManagerVMID interface. |
Good Luck!
相关文章推荐
- windows mobile开发循序渐进(6)windows mobile device center 使用问题
- 使用Windows Mobile Device Center进行手机的同步
- windows mobile开发循序渐进(6)windows mobile device center 使用问题
- 使用VS2008 在windows环境 编译Rtmpdump
- 使用Windows 10远程控制Ubuntu 16.04
- Windows Mobile/Windows CE开发技巧 —— 使用钩子实现自定义系统功能键
- 使用Windows Mobile Test Framework进行Windows Mobile程序的自动化测试 - (1)微软Windows Mobile Test Framework简介
- windows下使用vs2008编译libuv库
- libimobiledevice与ideviceinstaller使用
- Git 版本控制工具使用介绍------Windows系统下使用
- 使用.Net编写Windows程序,对于窗体控制常见项目
- 谈谈使用VFW在windows下编程控制摄像头
- msysgit + TortoiseGit:在 windows 上安装配置版本控制工具 Git 图形化使用
- 使用TeamViewer,windows远程控制ubuntu
- 使用windows route命令来控制双网卡,双网络访问
- “此iPhone不能使用,因为Apple Mobile Device服务没有启动”解决办法
- 谈谈使用VFW在windows下编程控制摄像头(一)。
- 张高兴的 Windows 10 IoT 开发笔记:使用 ULN2003A 控制步进电机
- C# 使用windows程序控制window服务
- 【版本控制】Github for Windows客户端的使用