Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
[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
Niet-null-interfaces vrijgeven.
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.
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.
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);
}
}
}
Verwante onderwerpen
-
VDS- gebruiken