iWMDMDevice::GetFormatSupport 方法 (mswmdm.h)

GetFormatSupport 方法检索设备支持的所有格式,包括编解码器和文件格式。

语法

HRESULT GetFormatSupport(
  [out] _WAVEFORMATEX **ppFormatEx,
  [out] UINT          *pnFormatCount,
  [out] LPWSTR        **pppwszMimeType,
  [out] UINT          *pnMimeTypeCount
);

参数

[out] ppFormatEx

指向 _WAVEFORMATEX 结构的数组的指针,这些结构指定有关设备支持的编解码器和比特率的信息。 Windows Media 设备管理器为此参数分配内存;调用方必须使用 CoTaskMemFree 释放它。

[out] pnFormatCount

指向 ppFormatEx 数组中元素数的指针。

[out] pppwszMimeType

指向描述设备支持的文件格式和数字权限管理方案的数组的指针。 Windows Media 设备管理器为此参数分配内存;调用方必须使用 CoTaskMemFree 释放它。

[out] pnMimeTypeCount

指向 pppwszMimeType 数组中的元素数的指针。

返回值

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

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

注解

检索设备支持的格式的建议方法是 IWMDMDevice3::GetFormatCapability

示例

以下 C++ 函数检索各种设备功能。


// Function to print out device caps for a device that supports
// only IWMDMDevice.
void GetCaps(IWMDMDevice* pDevice)
{
    HRESULT hr = S_OK;

    // Get all capabilities for audio and mime support.
    _WAVEFORMATEX* pAudioFormats;
    LPWSTR* pMimeFormats;
    UINT numAudioFormats = 0;
    UINT numMimeFormats = 0;
    hr = pDevice->GetFormatSupport(
        &pAudioFormats,
        &numAudioFormats,
        &pMimeFormats,
        &numMimeFormats);

    HANDLE_HR(hr, "Got audio and mime formats in GetCaps IWMDMDevice", "Couldn't get audio and mime formats in GetCaps IWMDMDevice");

    // Print out audio format data.
    if (numAudioFormats > 0)
    {
        / /TODO: Display a banner to precede the supported formats.
    }
    else
    {
        // TODO: Display a message indicating that no formats are supported.
    }
    for(int i = 0; i < numAudioFormats; i++)
    {
        // TODO: Display a configuration value.
        PrintWaveFormatGuid(pAudioFormats[i].wFormatTag);
        // TODO: Display a max channel value.
        // TODO: Display a max samples/second value.
        // TODO: Display the max bytes/second value.
        // TODO: Display the block alignment value.
        // TODo: Display the max bits/sample value.
    }

    // Print out MIME formats.
    if (numMimeFormats > 0)
        // TODO: Display a banner for the MIME format listing.
    else
        / /TODO: Display a message indicating that no MIME formats are supported.
    for(i = 0; i < numMimeFormats; i++)
    {
        // TODO: Display each individual MIME format.
    }

e_Exit:
    return;

}

要求

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

另请参阅

发现设备格式功能

IWMDMDevice 接口

IWMDMDevice3::GetFormatCapability

_WAVEFORMATEX