使Vb / c ++ / C#应用程序静音

Geo*_*rig -1 c# c++ vb.net internet-explorer mute

我需要使我的应用程序静音,因为它使用5个Web浏览器并导航到带有Flash的网站,这可能会引起很多烦人的声音,因此我到处搜索,但是没有运气,我想知道是否有一种方法可以使我的应用程序或我的应用程序静音通过vb代码或任何其他语言的网络浏览器(我将制作一个插件)。在此先感谢您的帮助。

Dan*_*eih 5

在Windows Vista和更高版本上,您可以通过调用内部的函数来设置单个应用程序的音量winmm.dll

[DllImport("winmm.dll")]
private static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
Run Code Online (Sandbox Code Playgroud)

并调用以下静态方法:

public static void MuteApplication()
{
  int NewVolume = 0;
  uint NewVolumeAllChannels = (((uint)NewVolume & 0x0000ffff) | ((uint)NewVolume << 16));
  waveOutSetVolume(IntPtr.Zero, NewVolumeAllChannels);
}
Run Code Online (Sandbox Code Playgroud)