正如我刚刚发现的那样,友好的名字不能保证是独一无二的。如果我可以从该标识符实例化过滤器而不必枚举它们,则可以获得奖励。
答案 0 :(得分:4)
WaveOutId可以识别包装WaveOut设备的渲染器过滤器。 DSGuid可以识别那些包装DirectSound设备。
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();
}