IWMDMDevice3::GetFormatCapability 方法 (mswmdm.h)

GetFormatCapability 方法检索设备对指定格式的文件的支持。 这些功能表示为支持的属性及其允许的值。

语法

HRESULT GetFormatCapability(
  [in]  WMDM_FORMATCODE        format,
  [out] WMDM_FORMAT_CAPABILITY *pFormatSupport
);

参数

[in] format

表示查询格式的 WMDM_FORMATCODE 枚举中的值。

[out] pFormatSupport

指向返回 的WMDM_FORMAT_CAPABILITY 结构的指针,该结构包含支持的属性及其允许的值。 这些值必须由应用程序释放,如在 支持 IWMDMDevice3 的设备上获取格式功能中所述。

返回值

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

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

注解

客户端可以使用 IWMDMDevice3::GetProperty 方法查询 g_wszWMDMFormatsSupported 设备属性来获取支持格式的列表。

对于特定格式,客户端可以调用此函数来获取支持的属性,并获取有关支持属性配置的信息, (例如比特率和采样率的组合) 。 此信息表示为格式功能。

示例

以下函数将传递设备指针和格式代码,并检索该设备针对该格式的格式功能。 函数使用自定义函数清除检索到的值。 此自定义函数显示在 支持 IWMDMDevice3 的设备上获取格式功能


// Each format configuration is described by a WMDM_FORMAT_CAPABILITY enum, and
// has a WMDM_FORMAT_CAPABILITY structure describing the device capabilities for that format.
//        Each WMDM_FORMAT_CAPABILITY structure has a WMDM_PROP_CONFIG structure listing configurations.
//            Each WMDM_PROP_CONFIG has a WMDM_PROP_DESC describing a specific format configuration.
//                Each WMDM_PROP_DESC holds specific values as a range, a set, or a flag meaning all values are accepted.
HRESULT myGetFormatCaps(WMDM_FORMATCODE formatCode, IWMDMDevice3* pDevice)
{
    HRESULT hr = S_OK;

    // Get a list of supported configurations for the format.
    WMDM_FORMAT_CAPABILITY formatCapList;
    hr = pDevice->GetFormatCapability(formatCode, &formatCapList);
    HANDLE_HR(hr, "Got a WMDM_FORMATCODE structure in GetCaps","Couldn't get a WMDM_FORMATCODE structure in GetCaps");

    // Print out the format name.
    // TODO: Display a banner for device formats.
    PrintWMDM_FORMATCODE(formatCode); // Custom function to print out the format code.
    

    // Loop through the configurations and examine each one.
    for(UINT iConfig = 0; iConfig < formatCapList.nPropConfig; iConfig++)
    {
        WMDM_PROP_CONFIG formatConfig = formatCapList.pConfigs[iConfig];

        // Preference level for this configuration (lower number means more preferred).
        // TODO: Display a banner for the preference-level output.

        // Loop through all properties for this configuration and get supported
        // values for the property. Values can be a single value, a range, 
        // or a list of enumerated values.
        for(UINT iDesc = 0; iDesc < formatConfig.nPropDesc; iDesc++)
        {
            WMDM_PROP_DESC propDesc = formatConfig.pPropDesc[iDesc];
            // TODO: Display the property name.

            // Three ways a value can be represented: any, a range, or a list.
            switch (propDesc.ValidValuesForm)
            {
                case WMDM_ENUM_PROP_VALID_VALUES_ANY:
                    // TODO: Display a message indicating that all values are valid.
                    break;
                case WMDM_ENUM_PROP_VALID_VALUES_RANGE:
                    {
                        // List these in the docs as the propvariants set.
                        WMDM_PROP_VALUES_RANGE rng = propDesc.ValidValues.ValidValuesRange;
                        // TODO: Display a banner for the values to follow
                        // TODO: Display the max value.
                        // TODO: Display the min value.
                        // TODO: Display the step value.
                    }
                    break;
                case WMDM_ENUM_PROP_VALID_VALUES_ENUM:
                    {
                        // TODO: Display a banner for the values to follow.
                        WMDM_PROP_VALUES_ENUM list = propDesc.ValidValues.EnumeratedValidValues;
                        PROPVARIANT pVal;
                        for(UINT iValue = 0; iValue < list.cEnumValues; iValue++)
                        {
                            pVal = list.pValues[iValue];
                            // TODO: Display the current value.
                            PropVariantClear(&pVal);
                            PropVariantInit(&pVal);
                        }
                    }

                    break;
                default:
                    HANDLE_HR(E_FAIL, "Undefined configuration type in GetCaps" << endl, "");
                    break;
            }
        }
    }
    // Now clear the memory used by WMDM_FORMAT_CAPABILITY.
    FreeFormatCapability(formatCapList);

e_Exit:
    return hr;
}

要求

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

另请参阅

发现设备格式功能

IWMDMDevice3 接口