Anyone know how to programmatically mute the Windows XP Volume using C#?
A:
You will probably want to use MCI commands: http://msdn.microsoft.com/en-us/library/ms709461(VS.85).aspx
I should add that while this will give you good general control over the input and output mixers in windows, you may have some difficulty with doing detailed controls, like setting the mic boost, etc.
Oh, and if you're on Vista, then just forget it. It's a totally different model.
This is a well documented tutorial. Nice catch!
Pascal Paradis
2008-09-30 17:37:44
Remember that this only works for Windows XP. Under Vista, it will only mute sounds made by the same application, not others.
Martin Plante
2008-10-01 13:52:59
A:
You could use P/Invoke as explained here: http://www.microsoft.com/indonesia/msdn/pinvoke.aspx. It actually goes through the steps in Task 1: Mute and Unmute Sound near the top.
Jim B-G
2008-09-30 17:33:08
+1
A:
I came across this project that might be of interest, if you're running Vista.
itsmatt
2008-09-30 17:34:37
+3
A:
Declare this for P/Invoke:
private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int WM_APPCOMMAND = 0x319;
[DllImport("user32.dll")]
public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
And then use this line to mute/unmute the sound.
SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle, (IntPtr) APPCOMMAND_VOLUME_MUTE);
smink
2008-09-30 17:35:18