Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mute Windows with WPF?

I am learning C# and WPF and had an idea for a little utility. I want a big red button that will do only one thing: completely mute/un-mute all Windows sounds (system beeps, WMP, DVD player, etc...) I've explored the object browser in VS 2008 but can't seem to find what I need: A mute that will affect all of Windows.

Is it System.Windows.Input.MediaCommands.MuteVolume and I'm just not getting how to use it?

Thanks for any pointers in the right direction using C# and/or WPF. :)

like image 322
Peter Avatar asked Feb 28 '10 14:02

Peter


1 Answers

I'm pretty sure that command is used by the individual WPF controls for muting. For instance, if the CommandTarget were a MediaElement, it would mute its sound when that command was executed. Unfortunately, I think you're going to have to do a bit more work. A quick google gave some examples for doing the p/invoke way, which is probably the only way to do it as of now in .NET:

For XP: MSDN

For Vista/7: CodeProject

like image 67
Abe Heidebrecht Avatar answered Sep 29 '22 15:09

Abe Heidebrecht