Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
[Windows 8 ve Windows Server 2012'de başlayarak, Sanal Disk Hizmeti COM arabiriminin yerini Windows Depolama Yönetimi API'sinin.]
Aşağıdaki kod örneği, IEnumVdsObject arabirimini kullanarak çağıranın numaralandırma nesneleriyle nasıl çalıştığını gösterir. Bir numaralandırma nesnesi tarafından döndürülen bilgilerin statik olduğunu unutmayın. Yeni yapılandırma değişikliklerini görmek için nesneyi yeniden sorgulamanız gerekir.
GetControllerById işlevi, pSubsystem parametresi tarafından belirtilen IVdsSubSystem arabirimini kullanarak alt sistemdeki denetleyicileri sorgular ve döndürülen numaralandırmada pControllerId parametresi tarafından belirtilen GUID ile eşleşen denetleyiciyi arayarak üzerinde döngü yapar. Eşleşen bir denetleyici bulunursa, S_OK HRESULTile birlikte ppController parametresi tarafından döndürülür.
//
// Simple macro to release non-null interfaces.
//
#include <windows.h>
#include "vds.h"
#include <stdio.h>
#define _SafeRelease(x) {if (NULL != x) { x->Release(); x = NULL; } }
HRESULT GetControllerById(
IN IVdsSubSystem *pSubsystem,
IN CONST VDS_OBJECT_ID *pControllerId,
OUT IVdsController **ppController)
{
VDS_CONTROLLER_PROP vdsControllerProperties;
IEnumVdsObject *pEnumController = NULL;
IVdsController *pController = NULL;
IUnknown *pUnknown = NULL;
HRESULT hResult = S_OK;
ULONG ulFetched = 0;
BOOL bDone = FALSE;
ZeroMemory(&vdsControllerProperties, sizeof(VDS_CONTROLLER_PROP));
// Query for the enumeration of controllers belonging
// to the given subsystem.
hResult = pSubsystem->QueryControllers(&pEnumController);
if (SUCCEEDED(hResult) && (!pEnumController))
{
hResult = E_UNEXPECTED; // Errant provider,
// returned S_OK
// with a NULL pointer.
}
if (SUCCEEDED(hResult))
{
// Enumerate through all the controllers this subsystem
// contains to find the controller of interest.
while (!bDone)
{
ulFetched = 0;
hResult = pEnumController->Next(1, &pUnknown, &ulFetched);
if (hResult == S_FALSE)
{
hResult = E_INVALIDARG;
break;
}
if (SUCCEEDED(hResult) && (!pUnknown))
{
hResult = E_UNEXPECTED; // Errant provider,
// returned S_OK with
// a NULL pointer
}
// Use an IVdsController interface to get the controller
// properties and check for the desired GUID.
if (SUCCEEDED(hResult))
{
hResult = pUnknown->QueryInterface(IID_IVdsController,
(void **) &pController);
}
if (SUCCEEDED(hResult) && (!pController))
{
hResult = E_UNEXPECTED; // Errant provider,
// returned S_OK
// with a NULL pointer
}
if (SUCCEEDED(hResult))
{
hResult = pController->
GetProperties( &vdsControllerProperties);
}
if (SUCCEEDED(hResult)
&& IsEqualGUID(*pControllerId, vdsControllerProperties.id))
{
bDone = TRUE;
}
else
{
_SafeRelease(pController);
}
_SafeRelease(pUnknown);
//Free the strings in the properties structure.
if (NULL != vdsControllerProperties.pwszIdentification)
{
CoTaskMemFree(vdsControllerProperties.pwszIdentification);
}
ZeroMemory(&vdsControllerProperties, sizeof(VDS_CONTROLLER_PROP));
}
}
if (SUCCEEDED(hResult))
{
*ppController = pController;
}
_SafeRelease(pEnumController);
return hResult;
}
İlgili konular
-
VDS Kullanma