Retrieving the Functional Object Identifiers for a Device
Previous | Next |
Retrieving the Functional Object Identifiers for a Device
As noted in the Retrieving the Functional Categories Supported by a Device topic, Windows Portable Devices may support one or more functional categories. Any given functional category may support one or more functional objects. For example, the storage category may support three functional storage objects, each of which is identified by a unique identifier string. The first storage object may then be identified by the string "Storage1", the second by the string "Storage2", and the third by the string "Storage3".
The ListFunctionalObjects function in the DeviceCapabilities.cpp module demonstrates the retrieval of content types for the functional categories supported by a selected device.
Your application can retrieve the functional categories supported by a device using the interfaces described in the following table.
Interface | Description |
IPortableDeviceCapabilities Interface | Provides access to the functional-category retrieval methods. |
IPortableDevicePropVariantCollection Interface | Used to enumerate and store functional-category data. |
The code found in the ListFunctionalObjects function is almost identical to the code found in the ListFunctionalCategories function. (See the Retrieving Functional Categories Supported by a Device topic.) The one difference is the call to the IPortableDeviceCapabilities::GetFunctionalObjects method, which appears within the loop that iterates through the functional categories.
HRESULT hr = S_OK; CComPtr<IPortableDeviceCapabilities> pCapabilities; CComPtr<IPortableDevicePropVariantCollection> pCategories; DWORD dwNumCategories = 0; if (SUCCEEDED(hr)) { for (DWORD dwIndex = 0; dwIndex < dwNumCategories; dwIndex++) { PROPVARIANT pv = {0}; PropVariantInit(&pv;); hr = pCategories->GetAt(dwIndex, &pv;); if (SUCCEEDED(hr)) { // We have a functional category. It is assumed that // functional categories are returned as VT_CLSID // VarTypes. if ((pv.puuid != NULL) && (pv.vt == VT_CLSID)) { // Display the functional category name printf("Functional Category: "); DisplayFunctionalCategory(*pv.puuid); printf("\n"); // Display the object identifiers for all // functional objects within this category CComPtr<IPortableDevicePropVariantCollection> pFunctionalObjectIds; hr = pCapabilities->GetFunctionalObjects(*pv.puuid, &pFunctionalObjectIds;); if (SUCCEEDED(hr)) { printf("Functional Objects: "); DisplayFunctionalObjectIDs(pFunctionalObjectIds); printf("\n\n"); } else { printf("! Failed to get functional objects, hr = 0x%lx\n", hr); } } else { printf("! Invalid functional category found\n"); } } PropVariantClear(&pv;); } }
See Also
- IPortableDevice Interface
- IPortableDeviceCapabilities Interface
- IPortableDevicePropVariantCollection Interface
- Programming Guide
Previous | Next |