Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello,
I have a problem must to be resolved soon, I have looked for a lot of information and published in many forums, unfortunately, that is still not resolved .
I can get default render endpoint device by using IMMDeviceEnumerator::GetDefaultAudioEndpoint function, and get all endpoint by using other interface, But I did not find such a function similar to “SetDefaultEndpoint”, I can not change default endpoint device in my program, How to set default audio device in vista by code?
Thanks.
Posted
Updated 29-Apr-10 6:33am
v3

1 solution

Hi,

Microsoft does not provide a progmatic method for setting the default audio device. You could probably manipulate the registry directly to change the default audio device. On Windows XP and below the following will work:

Changing your Windows audio device programmatically using VC++[^]

On Vista and above the registry key is located at:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio

There is an undocumented/unsupported COM interface IPolicyConfig which is demonstrated here: http://eretik.omegahg.com/download/DefSound.rar[^]

Best Wishes,
-David Delaune
 
Share this answer
 
Comments
EreTIk_cp 17-May-10 9:28am    
Header file for using undocumented COM interface IPolicyConfig (method SetDefaultEndpoint(...) ):
http://eretik.omegahg.com/download/PolicyConfig.h

Tested on: Vitsa x32 SP2, Win7 x32/x64

*UPDATED*:
In new header file PolicyConfig.h IPolicyConfig renamed to IPolicyConfigVista. IPolicyConfig now is another (extended, undocumented) COM interface for Windows 7. Method IPolicyConfigVista::SetDefaultEndpoint(...) can be used on both OS: Vista and 7.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900