次の方法で共有


IDeviceEmulatorManager

更新 : 2007 年 11 月

このインターフェイスは、デバイス エミュレータ マネージャを表します。このオブジェクトを使用して、デバイス エミュレータ マネージャ (DEM: Device Emulator Manager) のウィンドウを制御し、[データストア]、[マイ デバイス エミュレータ]、[すべてのデバイス エミュレータ]、[その他] などのルート レベル ノードを反復処理します。

interface IDeviceEmulatorManager : IDispatch ();

メソッド

メソッド

説明

IDeviceEmulatorManager::EnumerateSDKs

現在のノードにあるプラットフォームを列挙します。

IDeviceEmulatorManager::ShowManagerUI

[デバイス エミュレータ マネージャ] ウィンドウを表示または非表示にします。

IDeviceEmulatorManager::MoveNext

次のノードに移動します。

IDeviceEmulatorManager::Reset

最初のノードに移動します。通常は [データストア] です。

IDeviceEmulatorManager::Refresh

[データストア] からの情報を再度読み取って、列挙体を更新します。

IDeviceEmulatorManager::get_Name

[データストア]、[マイ デバイス エミュレータ]、[すべてのデバイス エミュレータ]、[その他] など、現在のノードの名前を取得します。

IDeviceEmulatorManager::RegisterRefreshEvent

デバイス エミュレータ マネージャの更新イベントを登録します。

IDeviceEmulatorManager::UnRegisterRefreshEvent

更新イベントの登録をキャンセルします。

解説

このインターフェイスを実装するオブジェクトを作成するには、CoCreateInstance を使用します。

このインターフェイスを実装するオブジェクトは、DEM ウィンドウのすべてのルート レベル ノードを含むリンク リストです。

使用例

この例では、[デバイス エミュレータ マネージャ] ウィンドウで、ノード、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