IEnumManagerSDKs

更新:2007 年 11 月

此接口表示设备仿真器管理器 (DEM) 中的平台级节点,例如“Pocket PC 2003”或“Windows Mobile 5.0 Smartphone”。

interface IEnumManagerSDKs : IDispatch {}

方法

方法

说明

IEnumManagerSDKs::EnumerateVMIDs

枚举属于当前平台的仿真程序。

IEnumManagerSDKs::MoveNext

移至下一个平台。

IEnumManagerSDKs::Reset

移回第一个平台。

IEnumManagerSDKs::get_Name

获取当前平台的名称。

备注

若要创建实现此接口的对象,请使用 IDeviceEmulatorManager::EnumerateSDKs。实现此接口的对象是一个链接列表,其中包含节点中的所有平台。

示例

下面的示例将列出“设备仿真器管理器”窗口中的节点、SDK/平台和仿真程序。

int _tmain(int argc, _TCHAR* argv[])
{
    if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
    {
        // HRESULT is used to determine whether method calls are successful
        HRESULT hr;

        // Instantiate DeviceEmulatorManager (DEM) object.
        // This starts DvcEmuManager.exe in silent mode

        CComPtr<IDeviceEmulatorManager> pDeviceEmulatorManager;
        hr = pDeviceEmulatorManager.CoCreateInstance(__uuidof(DeviceEmulatorManager));
        if (FAILED(hr)) {
            wprintf_s(L"Error: Unable to instantiate DeviceEmulatorManager. ErrorCode=0x%08X\n", hr);
            return false;
        }

        // For each of the four nodes in the Device Emulator Manager window
        // (Datastore, My Device Emulators, All Device Emulators, and Others)  
        for (; SUCCEEDED(hr); (hr = pDeviceEmulatorManager->MoveNext()))
        {
            // Output the name of node
            CComBSTR node;
            hr = pDeviceEmulatorManager->get_Name(&node);
            if (FAILED(hr)) {
                wprintf_s(L"Error: Failed to get current SDK category name. ErrorCode=0x%08X\n", hr);
                return false;
            }
            wprintf_s(L"- %s\n", node);

            // Get a list of SDKs/platforms in this node
            CComPtr<IEnumManagerSDKs> pSDKEnumerator;
            hr = pDeviceEmulatorManager->EnumerateSDKs(&pSDKEnumerator);
            if (FAILED(hr)) {
                wprintf_s(L"Error: Failed to get enumerator for the SDK Category[%s]. ErrorCode=0x%08X\n", node, hr);
                return false;
            }

            // For every SDK/platform in the list
            for (; SUCCEEDED(hr); (hr = pSDKEnumerator->MoveNext()))
            {
                // Output its name
                CComBSTR sdkName;
                hr = pSDKEnumerator->get_Name(&sdkName);
                if (hr == E_ENUMSDK_NOT_LOADED ) {
                    continue;
                } else if (FAILED(hr)) {
                    wprintf_s(L"Error: Failed to get SDK details. ErrorCode=0x%08X\n", hr);
                    return false;
                }
                wprintf_s(L"\t- %s\n", sdkName);

                // Get the list of emulators in the SDK/platform
                CComPtr<IEnumVMIDs> pDeviceEnumerator;
                hr = pSDKEnumerator->EnumerateVMIDs(&pDeviceEnumerator);
                if (FAILED(hr)) {
                    wprintf_s(L"Error: Failed to get enumerator for VM devices. ErrorCode=0x%08X\n", hr);
                    return false;
                }

                // For every emulator in the list
                for (; SUCCEEDED(hr); (hr = pDeviceEnumerator->MoveNext()))
                {
                    // Get the IDeviceEmulatorManagerVMID object.
                    CComPtr<IDeviceEmulatorManagerVMID> pDevice;
                    hr = pDeviceEnumerator->GetVMID(&pDevice);
                    if (FAILED(hr)) {
                        continue;
                    }

                    // Output the name of the emulator.
                    CComBSTR deviceName;
                    hr = pDevice->get_Name(&deviceName);
                    if (FAILED(hr)){
                        continue;
                    }
                    wprintf_s(L"\t\t%s\n", deviceName);
                }
            }
        }
        return true;
        CoUninitialize();
    }
    return false;
}

要求

DEMComInterface.tlb

请参见

其他资源

Device Emulator samples(设备仿真程序示例)