Automating the Device Emulator Manager Using the IDeviceEmulatorManager Interface


Anand Balachandran, with contributions by Jim Wilson, JW Hedgehog, Inc.

October 2007

This resource provides sample applications that demonstrate how to use the new Device Emulator Manager automation interface APIs (that are part of Microsoft® Visual Studio® 2008) to configure, and programmatically perform all operations on the installed emulator images that are available interactively on the Device Emulator Manager drop-down and context menus.

Download DEMAutomationSetup.msi from the Microsoft Download Center.

Two samples are provided. The first is a C++ application that demonstrates how to access the Device Emulator Manager features through the native COM interfaces. The C++ sample application includes two main files that are of interest: DEMAutomation.cpp and DEMOperations.cpp. DEMAutomation.cpp contains the program’s entry point code that parses the command-line parameters and calls the corresponding Device Emulator Manager operation. DEMOperations.cpp contains the code that demonstrates the details of programmatically interacting with the Device Emulator Manager. The two primary interfaces used within the DEMOperations.cpp source file are IDeviceEmulatorManager and IDeviceEmulatorManagerVMID. The IDeviceEmulatorManager interface represents the Device Emulator Manager; the IDeviceEmulatorManagerVMID interface represents a specific instance of an emulator.

The second sample is a script application that demonstrates how to access the Device Emulator Manager features through the Automation interfaces. All Device Emulator Manager features are available through the automation interfaces.

C++ Sample Instructions
  1. Open the Visual Studio 2008 DEMAutomation.sln file by clicking Start and then selecting All Programs | Windows Mobile Developer Samples | DEMAutomation | DEMAutomation.

  2. In the Visual Studio 2008 Solution Explorer, right-click the DEMAutomation project and select Properties.

  3. In the left-pane of the DEMAutomation Property Pages, expand Configuration Properties, expand C/C++, and then select General.

  4. In the right-pane of the DEMAutomation Property Pages, select Additional Include Directories.

  5. Verify that the Additional Include Directories value correctly lists the location of the %Program Files%\Microsoft Device Emulator\1.0 folder on your computer. If it is incorrect, modify the value appropriately. The project uses this path to locate the DEMComInterface.tlb type library that the stdafx.h header file imports.

  6. Click OK to dismiss the DEMAutomation Property Pages.

  7. Build the solution. It will generate the DEMAutomation.exe file.

  8. The DEMAutomation.exe application uses command-line arguments to specify the application behavior. See the Usage section below for the list of supported command-line parameters.

Script Sample Instructions
  1. Open a command prompt by clicking Start, and then select All Programs, Microsoft Visual Studio 2008, Visual Studio Tools, Visual Studio 2008 Command Prompt.

  2. Change directory to the folder where you installed the DEMAutomation.vbs script file. By default, the DEMAutomation Sample installation installs the script file to %Program Files%\Windows Mobile Developer Samples\11-2007 DEMAutomation\Script

  3. Type DEMAutomation.vbs and press ENTER.

  4. If a message box appears, follow the directions on the message box to correctly execute the script file.

  5. Once you successfully execute the DEMAutomation.vbs script, the script will display the command-line arguments used to run the script.

  6. See the Usage section below for the list of supported command-line parameters.

Following are the command-line parameters supported by both the C++ application and the script file. The application and script file behaviors highlight the features of the Device Emulator Manager automation interfaces.

Name in the command-line parameters refers to the display name of the emulator as it appears in the Device Emulator Manager. VMID refers to the Virtual Machine Identifier, which is the globally unique identifier for a particular emulator. The easiest way to determine each of the emulator’s VMIDs is to run either the DEMAutomation application or script file with the List option, which lists the name and VMID of each installed emulator.


bringtofront [VMID|Name]

connect [VMID|Name]

cradle [VMID|Name]

clearsavestate [VMID|Name]

getconfiguration [VMID|Name] [existing device configuration file]

reset [VMID|Name]

uncradle [VMID|Name]

setconfiguration [VMID|Name] [device configuration file to create]

shutdown [VMID|Name]

Information for Managed Developers

The Device Emulator Manager Automation interfaces are accessible through the Microsoft.DeviceEmulatorManager.Interop.9.0.dll interoperability assembly located in %Program Files%Microsoft Device Emulator\1.0. This assembly provides managed versions of the interfaces demonstrated in the DEMAutomation application. All of the interfaces and classes contained in the assembly are part of the “Microsoft.DeviceEmulatorManager.Interop” namespace.

For a detailed discussion of developing managed applications with the Device Emulator Manager API, see How To: Programmatically Control the Windows Mobile Device Emulators from .NET.