I want to be able to change the default audio output device on Windows 7 programatically using C# (and probably some underlying Win32 API calls, as well). I've already done my homework, and I've heard a lot of mixed comments from different sources, so I wanted to ask this question again to get a straight answer. Is this actually possible (through any means)? If so, how would I go about doing this?
And please do not suggest a solution with "AutoIt" or some other similar program... this is a C#/.NET-specific question.
Here's how: In the search box on the taskbar, type control panel, then select it from the results. Select Hardware and Sound from the Control Panel, and then select Sound. On the Playback tab, select and hold (or right-click) the listing for your audio device, select Set as Default Device, and then select OK.
A little up-to-date answer, which is compatible with Windows 10.
This program is able to do it in a beautiful manner (hotkey to switch between pre-selected devices) and is written on C# : SoundSwitch on GitHub
Some reverse engineering should get you there (for my use this program was just perfect as it is).
It makes use of that library (same author) which is in C++ : AudioEndpointLibrary on GitHub
So if you know C++ (which I don't enough), you might go further in the analysis of how it works. Or just use the library like SoundSwitch does.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With