Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect when an audio device has been unplugged (windows vista) in C#

Tags:

c#

Id like to know how to detect when a device has been plugged in, and unplugged, and then mute / unmute the laptops internal speakers

like image 889
caesay Avatar asked Jan 27 '10 04:01

caesay


People also ask

How do I know if I have a Sound playback device?

Click or tap on the sound volume icon from the system tray, and then click/tap on the current playback device. The Sound flyout then shows you all the playback audio devices that are available for you to use.

Where can I find disabled audio devices in Windows 7?

Open Control panel. Click Hardware and Sound and then Click on Sounds. Under Playback tab, right click on the empty area and make sure “Show Disabled Devices” has a check mark on it. If headphones/Speakers are disabled, it will now show up in the list.


1 Answers

In unmanaged code you would listen for WM_DEVICECHANGE in your top level windowproc.

That appears to be the only way to do it in managed code as well.

like image 138
John Knoeller Avatar answered Nov 03 '22 10:11

John Knoeller