Setting default audio device in Windows

Since the audio revamp in Windows Vista, many things that were possible to do in code in the past (i.e. XP) are now difficult or impossible. One of those tasks that was easy in XP was setting the default audio device for playback. In XP this just required a registry change, but in Vista & Windows 7, Microsoft decided that developers should not have access to change the default audio device, so they locked down the registry and provided no documented API to achieve this. Their reasoning was that if two programs both wanted to set the default audio device, they would end up fighting each other for it, which of course is bad. But I believe this is a very short-sighted decision, since there are plenty of legitimate cases where a program needs to do this. These are discussed on this amazingly long-living thread (started in 2006 and still going).

The end result is that, no thanks to Microsoft, we finally have a way to do this, and I’ve created a console application in case others would like to control this as well:

Usage: SetDefaultAudioDevice.exe [deviceID] [role]
Where:
[deviceID] is a GUID including braces
[role] is either ‘console’, ‘multimedia’ or ‘communications’.

Example: SetDefaultAudioDevice {24dfc80a-680f-4748-8627-c340cb14f187} multimedia

Your audio device IDs can be found in the registry under HKLMSOFTWAREMicrosoftWindowsCurrentVersionMMDevicesAudioRender.

Feel free to download this utility here, source code is in my SVN repo.

Thank-you to EreTIk and Jonny Best and everyone else on the above forum post!

10 thoughts on “Setting default audio device in Windows

  1. demon_firefox says:

    Is there a method to get the current device? It would be rather helpful to write a “toggle” command.

  2. demon_firefox says:

    Is there a method to get the current device? It would be rather helpful to write a “toggle” command.

  3. marty says:

    I’ve searched a lot for a tool like this as I often need to switch audio between computer speakers and stereo speakers and want a hotkey toggle.

    But I run into a problem. On my Win7 x64 I get an error message about missing msvcp100.dll . I do have that file in C:\Windows\System32\msvcp100.dll and also some other application folders. I have tried to run SetDefaultAudioDevice.exe also in Win XP compatibility mode but it returns the same error message. When I copy the .dll to the same folder as SetDefaultAudioDevice.exe the error message changes to “unable to start correctly (0xc000007b)”.

    Any ideas on how to solve that problem?

  4. marty says:

    I’ve searched a lot for a tool like this as I often need to switch audio between computer speakers and stereo speakers and want a hotkey toggle.

    But I run into a problem. On my Win7 x64 I get an error message about missing msvcp100.dll . I do have that file in C:WindowsSystem32msvcp100.dll and also some other application folders. I have tried to run SetDefaultAudioDevice.exe also in Win XP compatibility mode but it returns the same error message. When I copy the .dll to the same folder as SetDefaultAudioDevice.exe the error message changes to “unable to start correctly (0xc000007b)”.

    Any ideas on how to solve that problem?

Comments are closed.