如何在 Vista 和 7 中全局静音和取消静音,并获得静音状态?
我现在正在使用旧的、良好的 Mixer API,但它在 Windows Vista 和 Windows 上无法按预期工作。 7.在正常情况下,在XP兼容模式下不行。它仅使当前应用程序静音,但我需要全局(硬件)静音。如何达到目标?有没有什么方法可以用纯 C/C++ 编写这个代码,无需 COM 接口和奇怪的调用?
I'm using the old good Mixer API right now, but it does not work as expected on Windows Vista & 7 in the normal, not in XP compatibility mode. It mutes the sound for the current app only, but I need a global (hardware) mute. How to rearch the goal? Is there any way to code this w/o COM interfaces and strange calls, in pure C/C++?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Vista 的音频堆栈被大幅重写。每个应用程序的音量和静音控制确实是新功能之一。使用 IAudioEndpointVolume 接口。
The audio stack was significantly rewritten for Vista. Per-application volume and mute control was indeed one of the new features. Strange calls will be required to use the IAudioEndpointVolume interface.
我最近处理了同样的问题。我们有一个使用声音系统进行警报的 Windows 应用程序。我们不能容忍用户无意中将音响系统静音。以下是我如何使用上面建议的接口来解决此问题:
在初始化期间,我添加了一个函数来初始化 IAudioEndpointVolume 类型的成员。这有点棘手,而且帮助并没有发挥应有的帮助。下面是如何做到这一点:
...
大约每秒一次,我添加了对以下内容的简单调用:
最后,当程序退出时,请记住释放分配的资源。
I recently dealt with this same issue. We have a Windows application that uses the sound system for alarms. We cannot abide the user muting the sound system inadvertently. Here is how I was able to use the interface suggested above to address this issue:
During initialization I added a function to initialize a member of type IAudioEndpointVolume. It was a bit tricky and the help wasn't as helpful as it could be. Here's how to do it:
...
About once per second I added a simple call to the following:
Finally, when the program exits just remember to release the allocated resource.