다음을 통해 공유


디바이스에 대한 기능 개체 식별자 검색

디바이스에서 지원하는 기능 범주 검색 항목에 설명된 대로 Windows 휴대용 디바이스는 하나 이상의 기능 범주를 지원할 수 있습니다. 지정된 기능 범주는 하나 이상의 기능 개체를 지원할 수 있습니다. 예를 들어 스토리지 범주는 각각 고유 식별자 문자열로 식별되는 세 가지 기능 스토리지 개체를 지원할 수 있습니다. 그런 다음 첫 번째 스토리지 개체는 문자열 "Storage1", 두 번째는 문자열 "Storage2"로, 세 번째 스토리지 개체는 "Storage3" 문자열로 식별할 수 있습니다.

DeviceCapabilities.cpp 모듈의 ListFunctionalObjects 함수는 선택한 디바이스에서 지원하는 기능 범주에 대한 콘텐츠 형식 검색을 보여 줍니다.

애플리케이션은 다음 표에 설명된 인터페이스를 사용하여 디바이스에서 지원하는 기능 범주를 검색할 수 있습니다.

인터페이스 Description
IPortableDeviceCapabilities 인터페이스 기능 범주 검색 메서드에 대한 액세스를 제공합니다.
IPortableDevicePropVariantCollection 인터페이스 기능 범주 데이터를 열거하고 저장하는 데 사용됩니다.

 

ListFunctionalObjects 함수에 있는 코드는 ListFunctionalCategories 함수에 있는 코드와 거의 동일합니다. (디바이스에서 지원하는 기능 범주 검색 항목을 참조하세요.) 한 가지 차이점은 기능 범주를 반복하는 루프 내에 표시되는 IPortableDeviceCapabilities::GetFunctionalObjects 메서드에 대한 호출입니다.

HRESULT hr = S_OK;
CComPtr<IPortableDeviceCapabilities>            pCapabilities;
CComPtr<IPortableDevicePropVariantCollection>   pCategories;
DWORD dwNumCategories = 0;

if (pDevice == NULL)
{
    printf("! A NULL IPortableDevice interface pointer was received\n");
    return;
}

// Get an IPortableDeviceCapabilities interface from the IPortableDevice interface to
// access the device capabilities-specific methods.
hr = pDevice->Capabilities(&pCapabilities);
if (FAILED(hr))
{
    printf("! Failed to get IPortableDeviceCapabilities from IPortableDevice, hr = 0x%lx\n",hr);
}

// Get all functional categories supported by the device.
// We will use these categories to enumerate functional objects
// that fall within them.
if (SUCCEEDED(hr))
{
    hr = pCapabilities->GetFunctionalCategories(&pCategories);
    if (FAILED(hr))
    {
        printf("! Failed to get functional categories from the device, hr = 0x%lx\n",hr);
    }
}

// Get the number of functional categories found on the device.
if (SUCCEEDED(hr))
{
    hr = pCategories->GetCount(&dwNumCategories);
    if (FAILED(hr))
    {
        printf("! Failed to get number of functional categories, hr = 0x%lx\n",hr);
    }
}

printf("\n%d Functional Categories Found on the device\n\n", dwNumCategories);

// Loop through each functional category and get the list of
// functional object identifiers associated with a particular
// category.
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);
    }
}

IPortableDevice 인터페이스

IPortableDeviceCapabilities 인터페이스

IPortableDevicePropVariantCollection 인터페이스

프로그래밍 가이드