iWMDMDevice3::GetProperty 方法 (mswmdm.h)

GetProperty 方法检索特定的设备元数据属性。

语法

HRESULT GetProperty(
  [in]  LPCWSTR     pwszPropName,
  [out] PROPVARIANT *pValue
);

参数

[in] pwszPropName

要检索的属性的宽字符、以 null 结尾的字符串名称。 元数据常量中提供了标准属性名称 常量的列表。

[out] pValue

属性的返回值。 应用程序必须使用 PropVariantClear 释放此内存。

返回值

该方法返回 HRESULT。 Windows Media 设备管理器 中的所有接口方法都可以返回以下任一类错误代码:

  • 标准 COM 错误代码
  • 转换为 HRESULT 值的 Windows 错误代码
  • Windows Media 设备管理器错误代码
有关可能错误代码的广泛列表,请参阅 错误代码

注解

若要获取受支持的设备属性列表,客户端调用此函数并指定 g_wszWMDMSupportedDeviceProperties。 有关标准设备属性名称的列表,请参阅 元数据常量

客户端应在 pValue 参数中传入指向空 PROPVARIANT 的指针。 返回时, pValue 将包含 属性的值。

此方法类似于用于存储的 GetMetadataGetSpecifiedMetadata 方法,但此方法一次只能获取一个属性。

示例

以下 C++ 代码查询 g_wszWMDMFormatsSupported 属性,该属性返回设备支持的格式的 SAFEARRAY 列表。


// Query a device for supported configurations for each media or format type. 
HRESULT GetCaps(IWMDMDevice3* pDevice)
{
    HRESULT hr = S_OK;

    // Request the "formats supported" property to get a list of supported formats.
    PROPVARIANT pvFormatsSupported;
    PropVariantInit(&pvFormatsSupported);
    hr = pDevice->GetProperty(g_wszWMDMFormatsSupported, &pvFormatsSupported);
    HANDLE_HR(hr, "Got a property list in GetCaps", "Couldn't get a property list in GetCaps.");

    // Loop through the retrieved format list.
    // For each format, get a list of format configurations.
    SAFEARRAY* formatList = pvFormatsSupported.parray;
    WMDM_FORMATCODE formatCode = WMDM_FORMATCODE_NOTUSED;
    for(LONG iCap = 0; iCap < formatList->rgsabound[0].cElements; iCap++)
    { 
        // Get a format from the SAFEARRAY of retrieved formats.
        SafeArrayGetElement(formatList, &iCap, &formatCode);

        // Call a custom function to see the specifics of device support for 
       // each format.
        if (formatCode != WMDM_FORMATCODE_NOTUSED)
            myGetFormatCaps(formatCode, pDevice);
    }

e_Exit:
    // Clear out the memory we used.
    PropVariantClear(&pvFormatsSupported);
    return hr;
}

要求

要求
目标平台 Windows
标头 mswmdm.h
Library Mssachlp.lib

另请参阅

枚举设备

IWMDMDevice3 接口

IWMDMDevice3::SetProperty

IWMDMStorage3::GetMetadata

IWMDMStorage4::GetSpecifiedMetadata

设置文件的元数据