本文介绍了如何唯一识别DirectShow音频渲染器过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我刚发现的那样,友好名称并不能保证唯一。奖励积分,如果我可以从该标识符实例化筛选器而不必枚举它们。

As I just found out the hard way, friendly names are not guaranteed to be unique. Bonus points if I can instantiate the filter from that identifier without having to enumerate them.

推荐答案

可以识别包装WaveOut设备的渲染器筛选器通过WaveOutId。那些包装好的DirectSound设备可以由DSGuid识别。

Renderer filters wrapping WaveOut devices can be identified by WaveOutId. Those wrapping DirectSound devices can be identified by DSGuid.

ICreateDevEnum* devices;
if (CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (LPVOID*)&devices) == S_OK)
{
    IEnumMoniker* enumerator;
    if (devices->CreateClassEnumerator(CLSID_AudioRendererCategory, &enumerator, 0) == S_OK)
    {
        IMoniker* moniker;
        while (enumerator->Next(1, &moniker, NULL) == S_OK)
        {
            IPropertyBag* properties;
            if (moniker->BindToStorage(NULL, NULL, IID_IPropertyBag, (void**)&properties) == S_OK)
            {
                VARIANT variant;
                VariantInit(&variant);
                if (properties->Read(L"WaveOutId", &variant, NULL) == S_OK)
                {
                    // variant.lVal now contains the id of the wrapped WaveOut device.
                }
                else if (properties->Read(L"DSGuid", &variant, NULL) == S_OK)
                {
                    // variant.bstrVal now contains an uppercase GUID.
                    // It's the same GUID you would get from DirectSoundEnumerate.
                }
                VariantClear(&variant);
                properties->Release();
            }
            moniker->Release();
        }
        enumerator->Release();
    }
    devices->Release();
}

这篇关于如何唯一识别DirectShow音频渲染器过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:53