다음을 통해 공유


IDeviceEmulatorManagerVMID

업데이트: 2007년 11월

이 인터페이스는 DEM(장치 에뮬레이터 관리자)의 단일 에뮬레이터를 나타냅니다. 이 인터페이스를 사용하여 에뮬레이터 연결, 크레들에 놓기, 다시 설정 등의 작업을 수행합니다.

interface IDeviceEmulatorManagerVMID : IDispatch{}

메서드

메서드

설명

IDeviceEmulatorManagerVMID::get_VMID

에뮬레이터를 고유하게 식별하는 VMID(가상 컴퓨터 식별자)를 가져옵니다.

IDeviceEmulatorManagerVMID::get_State

에뮬레이터의 현재 상태를 가져옵니다. 에뮬레이터는 실행 중이지 않거나, 실행 중이거나, 크레들에 놓여 있는 상태일 수 있습니다.

IDeviceEmulatorManagerVMID::get_Name

Pocket PC 2003 SE 에뮬레이터 같은 에뮬레이터의 이름을 가져옵니다.

IDeviceEmulatorManagerVMID::Connect

장치 에뮬레이터를 아직 시작하지 않았으면 시작하고 에뮬레이터에 연결합니다.

IDeviceEmulatorManagerVMID::Cradle

에뮬레이터를 크레들에 놓습니다.

IDeviceEmulatorManagerVMID::UnCradle

에뮬레이터를 크레들에서 제거합니다.

IDeviceEmulatorManagerVMID::Shutdown

에뮬레이터를 종료하고 선택적으로 에뮬레이터 상태를 저장합니다.

IDeviceEmulatorManagerVMID::Reset

에뮬레이터를 다시 설정합니다.

IDeviceEmulatorManagerVMID::ClearSaveState

이 장치와 연결된 장치 에뮬레이터 상태 저장 파일(.dess)을 지웁니다. 다음 번에 에뮬레이터를 시작하면 상태 저장 파일이 아닌 ROM 이미지에서 시작됩니다.

IDeviceEmulatorManagerVMID::BringToFront

장치 에뮬레이터 창을 표시합니다.

IDeviceEmulatorManagerVMID::GetConfiguration

장치 에뮬레이터 구성 XML 형식으로 된 에뮬레이터 구성을 가져옵니다.

IDeviceEmulatorManagerVMID::SetConfiguration

올바른 형식이 지정된 장치 에뮬레이터 구성 XML 문자열을 포함하는 에뮬레이터의 구성을 설정합니다.

설명

이 인터페이스를 구현하는 개체를 만들려면 IEnumVMIDs::get_VMID를 사용합니다.

예제

이 예제에서는 Pocket PC 2003 에뮬레이터를 시작하고 다양한 작업을 수행합니다.

BOOL FindDevice(const CComBSTR& deviceIdentifier, IDeviceEmulatorManagerVMID** pDeviceVMID);

int _tmain(int argc, _TCHAR* argv[])
{
    if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
    {
        HRESULT hr;
        CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;

        // Get the emulator by calling a helper function
        hr = FindDevice("Pocket PC 2003 SE Emulator", &pDevice);

        // If the emulator is found
        if (SUCCEEDED(hr))
        {
            // Output the name of the emulator
            CComBSTR deviceName;
            hr = pDevice->get_Name(&deviceName);
            if (SUCCEEDED(hr)) wprintf_s(L"Device Name: %s\n", deviceName);

            // Output the emulator's VMID
            CComBSTR VMID;
            hr = pDevice->get_VMID(&VMID);
            if (SUCCEEDED(hr)) wprintf_s(L"Device VMID: %s\n", VMID);

            // Output the emulator's current state
            EMULATOR_STATE deviceState = EMU_NOT_RUNNING;
            hr = pDevice->get_State(&deviceState);
            if (SUCCEEDED(hr))
            {
                if (deviceState == EMU_CRADLED) wprintf_s(L"Emulator is Cradled\n");
                else if (deviceState == EMU_RUNNING) wprintf_s(L"Emulator is Running\n");
                else wprintf_s(L"Emulator is Not Running\n");
            }

            // Connect to the emulator
            hr = pDevice->Connect();
            if (SUCCEEDED(hr)) wprintf_s(L"Emulator is connected\n");

            // Make the Device Emulator window visible
            hr = pDevice->BringToFront();
            if (SUCCEEDED(hr)) wprintf_s(L"Device Emulator window is on top\n");

            // Cradle the emulator
            hr = pDevice->Cradle();
            if (SUCCEEDED(hr)) wprintf_s(L"Emulator is cradled\n");
            system("pause");

            // Uncradle the emulator
            hr = pDevice->UnCradle();
            if (SUCCEEDED(hr)) wprintf_s(L"Emulator is uncradled\n");

            // Save state and shutdown the emulator
            hr = pDevice->Shutdown(true);
            if (SUCCEEDED(hr)) wprintf_s(L"Emulator is shutdown\n");

            // Delete the .dess save state file for this device
            hr = pDevice->ClearSaveState();
            if (SUCCEEDED(hr)) wprintf_s(L"Save state file is deleted");
            system("pause");
        }
    }
    return 0;
}

// Helper method to find a device given name or VMID
BOOL FindDevice(const CComBSTR& deviceIdentifier, IDeviceEmulatorManagerVMID** pDeviceVMID)
{
    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()))
    {
        CComPtr<IEnumManagerSDKs> pSDKEnumerator;


        // Get a list of SDKs/platforms in this node
        hr = pDeviceEmulatorManager->EnumerateSDKs(&pSDKEnumerator);
        if (FAILED(hr)) {
            continue;
        }

        // For every SDK/platform in the list
        for (; SUCCEEDED(hr); (hr = pSDKEnumerator->MoveNext()))
        {

            // Get the list of emulators in the SDK/platform
            CComPtr<IEnumVMIDs> pDeviceEnumerator;
            hr = pSDKEnumerator->EnumerateVMIDs(&pDeviceEnumerator);
            if (FAILED(hr)) {
                continue;
            }

            // For every emulator in the list
            for (; SUCCEEDED(hr); (hr = pDeviceEnumerator->MoveNext()))
            {
                CComBSTR deviceName;
                CComPtr<IDeviceEmulatorManagerVMID> pDevice;

                // Get the IDeviceEmulatorManagerVMID object.
                hr = pDeviceEnumerator->GetVMID(&pDevice);
                if (FAILED(hr)) {
                    continue;
                }

                // Get the name of the emulator
                hr = pDevice->get_Name(&deviceName);
                if (FAILED(hr)){
                    continue;
                }

                // If the name of the device matches the supplied name, 
                // then this is the device we are looking for. 
                if (deviceIdentifier == deviceName){
                    *pDeviceVMID = pDevice;
                    (*pDeviceVMID)->AddRef();
                    return TRUE;
                }
            }
        }
    }
    wprintf_s(L"Error: Unable to locate the device '%s'", deviceIdentifier);
    return FALSE;
}

요구 사항

DEMComInterface.tlb

참고 항목

기타 리소스

장치 에뮬레이터 샘플