Search code examples
c#c++vb.netinternet-explorermute

Mute Vb/c++/C# application


I need to mute my application because it's using 5 webbrowsers and navigates to sites with flash, this can cause a lot of annoying sound , so I searched everywhere but no luck I want to know if there is a way to mute either my application or my webbrowsers either through vb code or whatever other language (I will make a plug-in). Thanks in advance for your help.


Solution

  • On Windows Vista and later, you can set an individual application's sound volume by calling a function inside winmm.dll

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

    And call following static method:

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