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
程式庫 Mssachlp.lib

另請參閱

探索裝置格式功能

IWMDMDevice3 介面