Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Vid anropet IWiaMiniDrv::drvInitItemProperties för rotobjektet måste minidrivrutinen initiera följande WIA-egenskaper som beskriver enheten.
I följande kodexempel visas hur du initierar WIA_DPS_SERVICE_ID med hjälp av metoderna OpenPropertyStore och ReadDeviceProperty för att läsa PKEY_PNPX_ServiceId. Samma allmänna metod kan användas för att initiera var och en av enhetsegenskaperna.
HRESULT hr = S_OK;
IPropertyStore *pPropertyStore = NULL;
BSTR bstrPropertyValue = NULL;
//
// Open the current Property Store and keep it opened until all needed properties are read
//
if (SUCCEEDED(hr))
{
hr = OpenPropertyStore(&pPropertyStore);
if (FAILED(hr))
{
WIAS_ERROR((g_hInst, "Failed to open the Property Store for the current Function Instance, hr = 0x%08X", hr));
}
}
//
// Initialize WIA_DPS_SERVICE_ID
//
if (SUCCEEDED(hr))
{
hr = ReadDeviceProperty(pPropertyStore, &PKEY_PNPX_ServiceId, &bstrPropertyValue);
if (FAILED(hr))
{
WIAS_ERROR((g_hInst, "Failed to read the PKEY_PNPX_ServiceId device property, hr = 0x%08X", hr));
}
if ((SUCCEEDED(hr)) && (bstrPropertyValue))
{
WIAS_TRACE((g_hInst, "Service id: %ws", (LPWSTR)bstrPropertyValue));
hr = AddProperty(WIA_DPS_SERVICE_ID, WIA_DPS_SERVICE_ID_STR, RN, bstrPropertyValue);
if (FAILED(hr))
{
WIAS_ERROR((g_hInst, "Failed to add WIA_DPS_SERVICE_ID property to the property manager, hr = 0x%08X", hr));
}
}
if (bstrPropertyValue)
{
SysFreeString(bstrPropertyValue);
bstrPropertyValue = NULL;
}
}
//
// Repeat the same procedure for WIA_DPS_DEVICE_ID, WIA_DPS_GLOBAL_IDENTITY, and WIA_DPS_FIRMWARE_VERSION
//
//
// Close the Property Store
//
if (pPropertyStore)
{
pPropertyStore->Release();
pPropertyStore = NULL;
}