[wdmaudiodev] Re: How to change the preferred audio device programmatically

  • From: "Mathieu Routhier" <mrouthier@xxxxxxxxxxxxx>
  • To: <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Tue, 17 Aug 2004 10:12:57 -0400

Hello MomongaPenguin,

Unfortunately, there are no exposed APIs to do it simply.  The registry keys
that hold the selected audio device (the one selected in the control panel)
are ok to read but not to write, since the control panel does more than
simply writing to the keys; it also calls other private interfaces.
Therefore, the modification NEEDS to pass through the control panel if you
want to avoid potential problems.

You could pop the audio control panel and ask the user to change it
manually.  That sucks.

Here is a technique I designed to "programmatically" change the audio
device:
1) load mmsys.cpl
2) get the entry point ShowAudioPropertySheet and call it (it is a rundll32
entry point)
3) In a separate thread, use FindWindow() to discover the window.
4) navigate through the child windows and find the combo box with the
devices in it. Use Spy++ to discover the IDs you need.
5) change the selection in the combo box by sending messages.
6) the dialog is a property sheet, so you can send the appropriate message
to simulate a press of the OK button.

Unfortunately, the function does not take into account the nCmdShow param.
That means the dialog cannot be made invisible, and therefore, it is
inevitable to display the dialog for at least a fraction of a second.  I
hope this is helpful to you.

Good luck,
Mat

________________________________________
From: wdmaudiodev-bounce@xxxxxxxxxxxxx
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of ?? ???
Sent: Tuesday, August 17, 2004 6:39 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] How to change the preferred audio device
programmatically

Hello, I'm MomongaPenguin,
I'd like to know How to change the preferred audio device programmatically.
I've heard it was already discussed in the Yahoo Group message 738.
But I can not join the group, because it was already closed.
Please help me,
Thank you.

________________________________________
GANBARE! NIPPON!
Yahoo! JAPAN JOC OFFICIAL INTERNET PORTAL SITE
http://mail.ganbare-nippon.yahoo.co.jp/ 

******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.de/

Other related posts: