Delen via


Laden van VDS

[Vanaf Windows 8 en Windows Server 2012 wordt de Virtual Disk Service COM-interface vervangen door de Windows Storage Management API.]

VDS- laden en initialiseren

  1. Niet-null-interfaces vrijgeven.

  2. Roep de CoCreateInstance, CoCreateInstanceExof CoGetClassObject functie aan om een aanwijzer naar het servicelaadprogrammaobject te verkrijgen.

    CLSCTX_DISABLE_AAA kan niet worden opgegeven in deze oproep. Als CoInitializeSecurity- wordt aangeroepen, kan EOAC_DISABLE_AAA niet worden opgegeven in de parameter dwCapabilities.

  3. Roep de methode IVdsServiceLoader::LoadService aan om VDS te laden.

    Door NULL als de eerste parameter door te geven, wordt VDS geladen en geïnitialiseerd op de lokale host.

  4. Roep de methode IVdsService::WaitForServiceReady aan om te wachten tot de VDS-initialisatie is voltooid.

In het volgende codevoorbeeld wordt de service geïnitialiseerd die een aanwijzer naar het serviceobject retourneert.

#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- gebruiken

IVdsService::WaitForServiceReady

IVdsServiceLoader::LoadService

Installatie- en Serviceobjecten