Share via


VD 로드

[Windows 8 및 Windows Server 2012 가상 디스크 서비스 COM 인터페이스는 Windows Storage 관리 API로 대체됩니다.]

VDS를 로드하고 초기화하려면

  1. null이 아닌 인터페이스를 해제합니다.

  2. CoCreateInstance, CoCreateInstanceEx 또는 CoGetClassObject 함수를 호출하여 서비스 로더 개체에 대한 포인터를 가져옵니다.

    호출에서는 CLSCTX_DISABLE_AAA 지정할 수 없습니다. CoInitializeSecurity가 호출되면 dwCapabilities 매개 변수에 EOAC_DISABLE_AAA 지정할 수 없습니다.

  3. IVdsServiceLoader::LoadService 메서드를 호출하여 VDS를 로드합니다.

    NULL을 첫 번째 매개 변수로 전달하면 로컬 호스트에서 VDS가 로드되고 초기화됩니다.

  4. IVdsService::WaitForServiceReady 메서드를 호출하여 VDS 초기화가 완료되기를 기다립니다.

다음 코드 예제에서는 서비스 개체에 대한 포인터를 반환하는 서비스를 초기화합니다.

#include "initguid.h"
#include "vds.h"
#include <stdio.h>

#pragma comment( lib, "ole32.lib" )

//
// Simple macro to release non-null interfaces.
//
#define _SafeRelease(x) {if (NULL != x) { x->Release(); x = NULL; } }

void __cdecl main(void) 
{
    HRESULT hResult;
    IVdsService *pService = NULL;
    IVdsServiceLoader *pLoader = NULL;

    // For this, you first get a pointer to the VDS Loader
    // Launch the VDS service. 
    //

    hResult = CoInitialize(NULL);

    if (SUCCEEDED(hResult)) 
    {
    
        hResult = CoCreateInstance(CLSID_VdsLoader,
            NULL,
            CLSCTX_LOCAL_SERVER,
            IID_IVdsServiceLoader,
            (void **) &pLoader);

        // 
        // And then load VDS on the local computer.
        //
        if (SUCCEEDED(hResult)) 
        {
            hResult = pLoader->LoadService(NULL, &pService);
        }

        //
        // You're done with the Loader interface at this point.
        //
        _SafeRelease(pLoader); 
        
        if (SUCCEEDED(hResult)) 
        {
            hResult = pService->WaitForServiceReady();
            if (SUCCEEDED(hResult)) 
            {
                //
                // You obtained an interface to the service: pService.
                // This interface can now be used to query for providers 
                // and perform other operations. 
                //
                printf("VDS Service Loaded");
            }

        } 
        else 
        {
            printf("VDS Service failed hr=%x\n",hResult);
        }
    }
}

VDS 사용

IVdsService::WaitForServiceReady

IVdsServiceLoader::LoadService

설정 및 서비스 개체