作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我目前有这段代码,遍历默认设备(未显示)的 Audio Session 控件:
int sessionCount;
hr = audioSessionEnumerator->GetCount(&sessionCount);
if (FAILED(hr)) {
throw HRESULTException("audioSessionEnumerator->GetCount", hr);
}
IAudioSessionControl *audioSessionControl;
for (int i = 0; i < sessionCount; ++i) {
hr = audioSessionEnumerator->GetSession(i, &audioSessionControl);
if (FAILED(hr)) {
throw HRESULTException("audioSessionEnumerator->GetSession", hr);
}
LPWSTR displayName;
hr = audioSessionControl->GetDisplayName(&displayName);
if (FAILED(hr)) {
throw HRESULTException("audioSessionControl->GetDisplayName", hr);
}
std::wcout << displayName << std::endl;
CoTaskMemFree(displayName);
audioSessionControl->Release();
}
audioSessionEnumerator->Release();
我的混音器目前看起来像这样:
预期的输出是:
Steam Client Bootstrapper
melodysheep - The Face of Creation
System Sounds
然而,看到的输出是:
(blank line)
(blank line)
@%SystemRoot%\System32\AudioSrv.Dll,-202
这与将 GetDisplayName
替换为 GetIconPath
时的输出相同。
上面的代码出现了什么问题导致了这个问题?如果必须显示更多代码,请通知我。
最佳答案
如果您阅读了 GetDisplayName 的备注和 GetIconName在 MSDN 中,您会看到如果没有人设置这些函数,它们可以返回 NULL。 GetIconName 页面还指出,如果 sndvol 应用程序(您有其屏幕截图)实际上会查找主窗口的图标,如果它为 NULL,因此通过归纳法将查找显示名称的主窗口标题,如果它是不存在。
您可能想要查询 IAudioSessionControl2具有 GetProcessId 方法的接口(interface)可能会返回客户端进程 ID。此时您可以使用类似 this 的东西和 this尝试从主窗口中提取值以保持一致。
关于c++ - 调用 GetDisplayName 返回与 GetIconPath 相同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27088100/
我目前有这段代码,遍历默认设备(未显示)的 Audio Session 控件: int sessionCount; hr = audioSessionEnumerator->GetCount(&ses
我是一名优秀的程序员,十分优秀!