VDS yükleme
[Windows 8 ve Windows Server 2012'de başlayarak, Sanal Disk Hizmeti COM arabiriminin yerini Windows Depolama Yönetimi API'sinin.]
VDS yüklemek ve başlatmak için
Null olmayan arabirimleri serbest bırakın.
CoCreateInstanceişlevini çağırın, CoCreateInstanceExveya CoGetClassObject işlevini, hizmet yükleyici nesnesine bir işaretçi elde etmek için çağırın.
CLSCTX_DISABLE_AAA bu çağrıda belirtilemez. CoInitializeSecurity çağrılırsa EOAC_DISABLE_AAAdwCapabilities parametresinde belirtilemez.
VDS'yi yüklemek için IVdsServiceLoader::LoadService yöntemini çağırın.
İlk parametre olarak NULL geçirerek yerel konakta VDS yüklenir ve başlatılır.
VDS başlatma işleminin tamamlanmasını beklemek için IVdsService::WaitForServiceReady yöntemini çağırın.
Aşağıdaki kod örneği, hizmet nesnesine bir işaretçi döndüren hizmeti başlatır.
#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);
}
}
}
İlgili konular
-
VDS Kullanma