none
Programmatically Enable/Disable a "Sound Device"

    Question

  • I have tried several USB headsets made by two different vendors, all of which behave the same way on Windows 7 X 64 (in a way different from the way they work in Windows XP.)

    On the Windows 7 systems the output (speaker) portion intermittently stops operating.  This failure occurs about once every 30 to 40 minand is extremely annoying.

    I have discovered that if I first disabled the device and immediately reenable it using the "Sounds" dialog proper function is restored – that is the speaker speaks!

    If I can write a program that avoids opening the sound dialog, right clicking on the device, clicking disable, right clicking on the device a second time, clicking on enable and then closing the sound dialog .  Not only will I save myself a lot of time but also a great deal of annoyance/aggravation.

    I am physically impaired and use Dragon NaturallySpeaking to perform many functions.  If I could write a program to perform this task a simple voice command would accomplish the same thing – much to my relief.

    The problem is: I have no idea what the interface is between Visual C++ and the sound devices or, for that fact, if there is one.

    If some kind soul would guide me through this I would be deeply grateful. No

    GUI is required (or is desired.)

    Thanks,


    Steve Behman


    • Edited by Steve Behman Friday, April 13, 2012 8:54 PM
    • Moved by Helen Zhao Monday, April 16, 2012 3:07 AM (From:Visual C++ General)
    Friday, April 13, 2012 8:49 PM

Answers

All replies

  • Hi Steve,

    According to the description, I’d like to move this thread to "Windows Hardware WDK and Driver Development" forum for better support.

    Thanks for your understanding.
    Best regards,


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    Monday, April 16, 2012 3:07 AM
  • the WDK sample devcon is exactly what you want, http://code.msdn.microsoft.com/windowshardware/DevCon-Sample-4e95d71c. specifically devcon disable. it is a cmd line application, so if you want to control it and dragon does not let you, you would have to write a simple GUI app based on devcon to do so.


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, April 16, 2012 4:58 AM
    Owner
  • Doron, thanks for the response.

    I followed the link you provided but unfortunately these are the results:

    The page does not exist

    Sorry, the page you requested was not found.

    If you would like to contact us regarding this, please click here.

    Return to the Windows Hardware Development Samples Home Page.

    Would you please correct the link?

    Again thanks,


    Steve Behman

    Monday, April 16, 2012 12:08 PM
  • remove the  full stop at the end of the link

    ie http://code.msdn.microsoft.com/windowshardware/DevCon-Sample-4e95d71c.  <------- remove the dot

    or click this

    http://code.msdn.microsoft.com/windowshardware/DevCon-Sample-4e95d71c



    • Edited by blufferisme Monday, April 16, 2012 1:01 PM hyperlinked
    Monday, April 16, 2012 12:54 PM
  • Doron, again thanks.

    In order to use the sample C++ project I had to update Visual C++ from the 2008 version to the 2010.  That done, I tried to build the sample but the bill did not succeed – the error message indicated that

    WindowsApplicationForDrivers8.0

    was missing.

    Do you have any idea where I can find this package?

    By the way: I really do not want to GUI for this purpose.  I needed a .exe or .CMD which I can place on the Desktop and, in turn, invoke using a voice command to be executed by Dragon.

    Thanks,


    Steve Behman


    Monday, April 16, 2012 5:24 PM
  • to use the online sample you need to VS2011 Consumer Preview, not VS2010. alternatively, you can download the win7 WDK which will have the sample and a self contained command line build environment.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, April 16, 2012 6:01 PM
    Owner
  • Doron, 

    I was able to obtain an appropriate version of Devcon.

    From the headset's properties dialog in Device Manager I obtained the following Hardware IDs:

    USB\VID_047F&PID_0410&REV_2133&MI_00

    USB\VID_047F&PID_0410&MI_00

    From which I constructed the file "speaker.CMD" which reads:

    Devcon.exe disable   "USB\VID_047F&PID_0410&MI_00"
    Devcon.exe  enable  "USB\VID_047F&PID_0410&MI_00"

    The following is a copy of the output when running Speaker.CMD:

    d:\Programs>speaker

    d:\Programs>Devcon.exe disable  "USB\VID_047F&PID_0410&MI_00"
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : Disable failed
    No matching devices found.

    d:\Programs>Devcon.exe  enable  "USB\VID_047F&PID_0410&MI_00"
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : Enable failed
    No matching devices found.

    I have tried numerous syntactical variations but none of them seems to work. Any advice?
    Also, I haven't a clue where the underscored line in the command output comes from – do you have any ideas about that?


    Steve Behman

    Tuesday, April 17, 2012 5:52 PM
  • the underlined text is the device instance that matches the hardware ID you passed. IIRC, there is a syntax using @ that allows you to specify the instance to enable/disable or perhaps some other commands

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, April 17, 2012 7:23 PM
    Owner
  • Doron, would you please correct the syntax of the Devcon.CMD so that it works.  I cannot find how the "@" should be applied.

    Devcon.exe disable   "USB\VID_047F&PID_0410&MI_00"
    Devcon.exe  enable  "USB\VID_047F&PID_0410&MI_00"

    Thanks,


    Steve Behman

    Tuesday, April 17, 2012 8:23 PM
  • The use of @ character is documented in kb311272 here

    A pre-built devcon.exe can be downloaded there too (old version, 2003)

    -- pa

    Tuesday, April 17, 2012 10:59 PM
  • Pavel,

    I am using the February 8, 2010 version of Devcon.exe – it seems to be the latest one.

    In the KB article to which you referred there are eight occurrences of the "@" all of which occurred in examples with absolutely no mention of it syntactical effect.

    I have tried all variants of the use of "'" and "@", none of them worked.

    Below is the command I am attempting to use.  The Hardware ID was obtained from the "Properties" dialog for the device.

    =================  SPEAKER.CMD  =============

    Devcon.exe disable   "'@USB\VID_047F&PID_0410&MI_00"
    Devcon.exe  enable  "'@USB\VID_047F&PID_0410&MI_00"

    ===================================================

    Since I have spent over 15 hours trying to make this work, the most helpful thing anyone can do at this point is to correct the above so that it works!

    Thanks,

     


    Steve Behman

    Wednesday, April 18, 2012 2:45 PM
  • Hi Steve,

    Try this: (note * at end)

     devcon.exe disable "@USB\VID_047F&PID_0410&MI_00*"

    Unfortunately Vista R2 (a.k.a Win7) is not 100% compatible with all hardware that happily works with XP.  We only can hope Win8 won't aggravate this further.

    Also unfortunate is that PnP terminology is so confusing, and not quite intuitive. Many of us spent tens of hours to grok it.

    Regards,

    -- pa

    Wednesday, April 18, 2012 5:41 PM
  • Pavel, this is the result of your suggestion:

    d:\>devcon.exe disable "@USB\VID_047F&PID_0410&MI_00*"
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : Disable failed
    No matching devices found.

    Following advice in another forum I got the following result:

    d:\>devcon find  "USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000"
    No matching devices found.

    d:\>devcon find  "@USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000"
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : CS50/CS60-USB Head
    set
    1 matching device(s) found.

    d:\>devcon disable  "@USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000"
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : Disable failed
    No matching devices found.

    d:\>devcon disable  "USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000"
    No matching devices found.

    Please note the underscored line (the emphasis is mine.)

    It appears that the use of the "@" changes the behavior of the "find" subcommand but does not affect the "disable" command, which, in no case, is similar to the "find" subcommand!

    All the above having been said, I am still a total loss in solving the problem.


    Steve Behman

    Wednesday, April 18, 2012 6:50 PM
  • So it found an instance but failed to disable it with status like "something not found".

    Probably you're kicking a phantom, non-present device instance left from unplugged USB device.

    Maybe its worth to install a new PCI USB host controller card, it may help with the headset failure.

    -- pa

    Wednesday, April 18, 2012 8:39 PM
  • Pavel, two things:

    On my motherboard there are two wholly independent USB controllers and I get the same failure when the device is plugged into either USB controller..

    Also, you'll note that one of the "find" commands did find the device and quite certainly since I am dictating to Dragon NaturallySpeaking using the device, it is definitely plugged in.  As further evidence I just disabled/enabled it using the "Sounds" dialog.

    From the above I'm fairly well convinced that your analysis is probably not correct but thank you so much for trying.


    Steve Behman

    Wednesday, April 18, 2012 9:06 PM
  • Hello folks, I am totally befuddled!

    I have found two versions of Devcon.exe both of which are dated 2/8/2010.  I have named one of

    them Devcon-old and the other Devcon-new (i.e. newer by 25 min.  and larger by 4 kB!) 

    Devcon-old was obtained from:  "\SDK\WinDDK\7600.16385.win7_wdk.100208-1538\tools\devcon

    \i386\devcon.exe" – the other was found elsewhere on the Web (I really don't remember where.)

    As can be observed from the outputs below they behave radically differently from one another. 

    Devcon-old is completely useless and will not be discussed further – all subsequent discussion of

    "Devcon" refers to Devcon-new.exe.


    If either the enable or restart subcommands are omitted after reboot the device completely

    disappears from the system.  That is it does not appear in "Device Manager" nor will "Scan for

    Hardware Changes" find the device.  Only running the restart subcommand and rebooting restores

    the device to device manager and the sounds dialog.

    The above gives rise to the question: Is there a newer version of Devcon (or something else) that

    really will disable a device without a reboot?

    If the answer to the above is "no" I am afraid I am on a fools errand!


    I would appreciate any guidance or comments.

    Thanks,

     

     

    ======  Speaker Command Output  Using "New" ==========

    d:\>Devcon-new find         "@USB\VID_047F*"
    USB\VID_047F&PID_0410&MI_03\6&14AB3D07&0&0003               : USB Input Device
    USB\VID_047F&PID_0410\5&35EDA8E7&0&1                        : USB Composite Device
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : CS50/CS60-USB Headset
    3 matching device(s) found.

    d:\>Devcon-new disable   "@USB\VID_047F*" 
    USB\VID_047F&PID_0410&MI_03\6&14AB3D07&0&0003               : Disabled
    USB\VID_047F&PID_0410\5&35EDA8E7&0&1                        : Disabled on reboot
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : Disabled on reboot
    The 3 device(s) are ready to be disabled. To disable the devices, restart thedevices or reboot the

    system .

    d:\>Devcon-new restart   "@USB\VID_047F*"
    USB\VID_047F&PID_0410&MI_03\6&14AB3D07&0&0003               : Restarted
    USB\VID_047F&PID_0410\5&35EDA8E7&0&1                        : Requires reboot
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : Requires reboot
    The 3 device(s) are ready to be restarted. To restart the devices, reboot the system.

    d:\>Devcon-new  enable  "@USB\VID_047F*"
    USB\VID_047F&PID_0410&MI_03\6&14AB3D07&0&0003               : Enabled
    USB\VID_047F&PID_0410\5&35EDA8E7&0&1                        : Enabled
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : Enabled
    3 device(s) are enabled.

    ======== Speaker Command Output Using ("Old") =======================

    d:\>Devcon-old find         "@USB\VID_047F*"
    USB\VID_047F&PID_0410&MI_03\6&14AB3D07&0&0003               : USB Input Device
    USB\VID_047F&PID_0410\5&35EDA8E7&0&1                        : USB Composite Device
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : CS50/CS60-USB Headset
    3 matching device(s) found.

    d:\>Devcon-old disable   "@USB\VID_047F*" 
    USB\VID_047F&PID_0410&MI_03\6&14AB3D07&0&0003               : Disable failed
    USB\VID_047F&PID_0410\5&35EDA8E7&0&1                        : Disable failed
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : Disable failed
    No matching devices found.

    d:\>Devcon-old restart   "@USB\VID_047F*"
    USB\VID_047F&PID_0410&MI_03\6&14AB3D07&0&0003               : Restart failed
    USB\VID_047F&PID_0410\5&35EDA8E7&0&1                        : Restart failed
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : Restart failed
    No matching devices found.

    d:\>Devcon-old  enable  "@USB\VID_047F*"
    USB\VID_047F&PID_0410&MI_03\6&14AB3D07&0&0003               : Enable failed
    USB\VID_047F&PID_0410\5&35EDA8E7&0&1                        : Enable failed
    USB\VID_047F&PID_0410&MI_00\6&14AB3D07&0&0000               : Enable failed
    No matching devices found.

    ============================================


    Steve Behman

    Thursday, April 19, 2012 2:55 PM
  • Doron et al,

    This is an update.

    I've been able to find a February 17, 2012 version of Devcon.exe (in the Windows Device Development Kit Version 8.0.

    Unfortunately this newer version still will not disable a device without a reboot, wholly defeating my intended purpose.

    As it appears that Devcon is the only programmatic interface to Device Manager, I am afraid that my desire to disable/reenable my USB headset will go unrequited.

    My thanks to all of you who tried to help me in my quest.

    Sincerely,


    Steve Behman

    Friday, April 20, 2012 5:07 PM
  • So basically you say that "devcon disable" cannot do something than Dev. Manager GUI does.

    I don't know. Maybe someone in MS could look at that.

    Also, it may be useful to set up tracing of the USB layer, to find out why exactly the headset fails. But this is quite much of hassle.

    --pa

    Saturday, April 21, 2012 4:10 PM
  • What you said seems to be true but, more importantly, there seems to be no way to do what can be done with the "Sounds" dialog GUI!

    Steve Behman

    Saturday, April 21, 2012 5:05 PM
  • devcon disable does exactly the same thing as device manager, sampe APIs

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Sunday, April 22, 2012 7:00 PM
    Owner
  • Doron,

    At this point I am quite certain that nothing in "Device Manager" or Devcon will do what I want to do.  These two facilities can make a device disappear and, in some cases, reappear in the system.

    It appears that these two capabilities operate at the device existence level rather than at the device function level where the "Sounds" dialog operates – i.e. the level where I need to act.

    Please recall that the action I want to happen is to exactly reproduce the effects of using the sound dialog to:

    Visually select the appropriate "Playback" device in the GUI and right-click on it.  Programmatically – this probably involves the use of an enumeration API and selecting a handle for the desired device from that enumeration.

     Left click on disable.  Programmatically – call the disable API with a handle found above.
    Right-click again on the same device – programmatically this is probably not needed,
    Left-click on enable.  Programmatically call the enable API  again using a handle obtained above.


    Steve Behman

    Sunday, April 22, 2012 11:10 PM
  • devcon was suggested because it appeared from your post that that you were successfully doing what you wanted to do from the device manager gui

    now your statement seems to be contradicting it

    i have no idea what you mean by sounds dialog

    do you mean the one that pops up when you do

    c:\> control mmsys.cpl

    from a commandprompt ?

    if i remember correctly it doesnt have anything named disable / enable in it

    anyway if you are successfully doing it from SOME X gui and you are happy with the result you can successfully

    use SendMessage() PostMessage()  Apis on Them after you find their handle using FindWindows() and Friends

    i just used spy++ to capture the keyboard interaction while i disabled and enabled my conexant hd audio from device manager gui

    the sequnence as follows

    hit the right click keyboard key

    click down key

    click enter key

    ok on msgbox

    repeat again for enabling

    and the relevent setupapi log pasted below

    C:\>type c:\devmgr.txt
    <00001> 000702D8 P WM_KEYDOWN nVirtKey:VK_APPS cRepeat:1 ScanCode:5D fExtended:1
     fAltDown:0 fRepeat:0 fUp:0
    <00002> 000702D8 P WM_KEYUP nVirtKey:VK_APPS cRepeat:1 ScanCode:5D fExtended:1 f
    AltDown:0 fRepeat:1 fUp:1
    <00003> 000702D8 P WM_KEYDOWN nVirtKey:VK_DOWN cRepeat:1 ScanCode:50 fExtended:1
     fAltDown:0 fRepeat:0 fUp:0
    <00004> 000702D8 P WM_KEYUP nVirtKey:VK_DOWN cRepeat:1 ScanCode:50 fExtended:1 f
    AltDown:0 fRepeat:1 fUp:1
    <00005> 000702D8 P WM_KEYDOWN nVirtKey:VK_DOWN cRepeat:1 ScanCode:50 fExtended:1
     fAltDown:0 fRepeat:0 fUp:0
    <00006> 000702D8 P WM_KEYUP nVirtKey:VK_DOWN cRepeat:1 ScanCode:50 fExtended:1 f
    AltDown:0 fRepeat:1 fUp:1
    <00007> 000702D8 P WM_KEYDOWN nVirtKey:VK_RETURN cRepeat:1 ScanCode:1C fExtended
    :0 fAltDown:0 fRepeat:0 fUp:0
    <00008> 000702D8 P WM_KEYDOWN nVirtKey:VK_APPS cRepeat:1 ScanCode:5D fExtended:1
     fAltDown:0 fRepeat:0 fUp:0
    <00009> 000702D8 P WM_KEYUP nVirtKey:VK_APPS cRepeat:1 ScanCode:5D fExtended:1 f
    AltDown:0 fRepeat:1 fUp:1
    <00010> 000702D8 P WM_KEYDOWN nVirtKey:VK_DOWN cRepeat:1 ScanCode:50 fExtended:1
     fAltDown:0 fRepeat:0 fUp:0
    <00011> 000702D8 P WM_KEYUP nVirtKey:VK_DOWN cRepeat:1 ScanCode:50 fExtended:1 f
    AltDown:0 fRepeat:1 fUp:1
    <00012> 000702D8 P WM_KEYDOWN nVirtKey:VK_DOWN cRepeat:1 ScanCode:50 fExtended:1
     fAltDown:0 fRepeat:0 fUp:0
    <00013> 000702D8 P WM_KEYUP nVirtKey:VK_DOWN cRepeat:1 ScanCode:50 fExtended:1 f
    AltDown:0 fRepeat:1 fUp:1
    <00014> 000702D8 P WM_KEYDOWN nVirtKey:VK_RETURN cRepeat:1 ScanCode:1C fExtended
    :0 fAltDown:0 fRepeat:0 fUp:0
    <00015> 000702D8 P WM_KEYUP nVirtKey:VK_RETURN cRepeat:1 ScanCode:1C fExtended:0
     fAltDown:0 fRepeat:1 fUp:1

    C:\>

    [2012/04/23 17:48:45 3408.4483]
    #-198 Command line processed: "C:\WINDOWS\system32\mmc.exe" C:\WINDOWS\system32\devmgmt.msc /s
    #-148 Loading coinstaller modules for "Conexant HD-Audio SmartAudio 221".
    #E360 An unsigned or incorrectly signed file "C:\WINDOWS\system32\UCI32A21.dll" for driver "Conexant HD-Audio SmartAudio 221" will be installed (Policy=Ignore). Error 0x800b0100: No signature was present in the subject.
    #I292 Changing device properties of "HDAUDIO\FUNC_01&VEN_14F1&DEV_5051&SUBSYS_103C30D9&REV_1000\4&15F3AEB8&0&0001".
    [2012/04/23 17:49:08 3408.5119]
    #-198 Command line processed: "C:\WINDOWS\system32\mmc.exe" C:\WINDOWS\system32\devmgmt.msc /s
    #-148 Loading coinstaller modules for "Conexant HD-Audio SmartAudio 221".
    #E360 An unsigned or incorrectly signed file "C:\WINDOWS\system32\UCI32A21.dll" for driver "Conexant HD-Audio SmartAudio 221" will be installed (Policy=Ignore). Error 0x800b0100: No signature was present in the subject.
    #I292 Changing device properties of "HDAUDIO\FUNC_01&VEN_14F1&DEV_5051&SUBSYS_103C30D9&REV_1000\4&15F3AEB8&0&0001".
    #I292 Changing device properties of "HDAUDIO\FUNC_01&VEN_14F1&DEV_5051&SUBSYS_103C30D9&REV_1000\4&15F3AEB8&0&0001".
    #I294 DICS_ENABLE DICS_FLAG_GLOBAL: Enabling device globally.

    Monday, April 23, 2012 12:32 PM
  • Thanks for the reply.

    The sound GUI dialog to which I refer is, in Windows 7, located in the Control Panel.  Insofar as I know this dialog has no keyboard (only a mouse) interface.  On the tab of interest (Playback) it presents a column of icons each representing a sound output device on the system.

    To accomplish my task: I must open the sounds dialog, position the pointer atop the CS50 icon, right-click on it which presents a context list, move the pointer to the "disable" item and left click it, reposition the pointer to the same icon, right-click it and then left click on the "enable" item in the context list and, finally, close the dialog.

    Please note that because I am seriously visually impaired (legally blind) the above is quite difficult for me to accomplish.

    Perhaps spy++ can trace the above actions but that is well beyond my level of sophistication.

    I would appreciate any ideas.


    • Edited by Steve Behman Monday, April 23, 2012 2:41 PM addenum
    Monday, April 23, 2012 2:17 PM
  • I asked the audio folks. the APIs the UI calls disable/enable are not public.  I think your next best bet will be to use the accessibility APIs to "script" the selection, right click, click on the menu item, etc to automate this process


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, April 23, 2012 4:16 PM
    Owner
  • Doron,

    Thank you for the sleuthing!   It is very difficult for me to understand why this is a private API but Microsoft, as always, has its own way of doing things.

    I haven't a clue how to do scripting to which you refer..

    Insofar as I'm visually impaired (legally blind) and 77 years old it is probably too difficult for me to learn a completely new paradigm.

    Thanks again for all your effort, it is truly appreciated.


    Steve Behman

    Monday, April 23, 2012 5:42 PM
  • well win7 indeed has a disable / enable thingy in mmsys.cpl

    i coded a Sample to enable disable and it seems to work in my win7 vm where i have only one entry the default speaker

    i

    i also paste below the code and output of the code on my win7 vm

    // disablesound.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include <windows.h>
    
    //mmsys.cpl is the sounds controlpanel applet 
    
    LPTSTR	 CmdLine = L"control.exe" L"mmsys.cpl";
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	int Disable = 0;
    	int getcres = 0;
    
    	// dumb and lame input gathering mechanism 
    	// yes you can use argv and parse commandline 
    	// and betterify this 
    
    waitforinput:
    	getcres = getchar();
    
    	if ( getcres == 'd' ) {
    		Disable = 1;
    	} else if ( getcres == 'e') {
    		Disable = 2;
    	} else {
    		printf("enter d or e only\n");
    		goto waitforinput;
    	}
    
    	//again lame and outdated unsupported Process Creation 
    	// You Should use CreateProcess as recommended
    
    	WinExec(
    		"c:\\windows\\system32\\control.exe c:\\windows\\system32\\mmsys.cpl",
    		SW_SHOWNORMAL
    		);
    
    	// CreateProcess and Waitforinputidle etc should be done instead of Sleeping
    
    	Sleep(8000);
    
    	// a loop which FindWindows the Sound Dialog 
    	// then loops into finding the ChildWindows
    	// Playback then SyslistView32 
    	// sets focus on the first entry (speaker)
    	// send a few more vk_downs if your entry is not first
    	// then finds the property window
    	// sends a disable or enable (vk_down / vk_up)
    	// and closes the dialog
    	// again uses sleep so be a good boy 
    	// and wait till the magic dissapears
    
    	HWND	SoundsDialogHandle;
    	if ( ( SoundsDialogHandle = FindWindow(
    		L"#32770",
    		L"Sound"
    		) ) == NULL) {
    			printf ( 
    				"Failed to Find Sounds Dialog Exiting\n"
    				);
    			return 0;
    	}
    	printf (
    		"Found Sound Dialog HWND is %x\n",
    		SoundsDialogHandle
    		);
    	SetFocus(SoundsDialogHandle);
    
    
    	HWND	SoundChildHandle;
    	if ( ( SoundChildHandle = FindWindowEx (
    		SoundsDialogHandle,
    		NULL,
    		L"#32770",
    		L"Playback"
    		) ) == NULL ) {
    			printf (
    				"Failed to Find Sounds Dialog Child Window Exiting\n"
    				);
    			return 0;
    	}
    
    	printf (
    		"Found Sound Dialog Child Window PlayBack HWND is %x\n",
    		SoundChildHandle
    		);
    	SetFocus(SoundChildHandle);
    
    	HWND SoundGrandChildHandleFirst;
    
    	if ( ( SoundGrandChildHandleFirst = FindWindowEx (
    		SoundChildHandle,
    		NULL,
    		L"SysListView32",
    		L""
    		) ) == NULL ) {
    			printf (
    				"Failed to Find Sounds Dialog GrandChildFirst Window Exiting\n"
    				);
    			return 0;
    	}
    
    	printf (
    		"Found Sound Dialog GrandChild First Window Properties Button HWND is %x\n",
    		SoundGrandChildHandleFirst
    		);
    
    	SetFocus(SoundGrandChildHandleFirst);
    
    	// setting focus on the first entry in syslistview
    	//if you have several entries send a few more vk_downs
    	// or play with lParam Repeat Count
    
    	PostMessage(
    		SoundGrandChildHandleFirst,
    		WM_KEYDOWN,
    		VK_DOWN,
    		0
    		);
    	PostMessage(
    		SoundGrandChildHandleFirst,
    		WM_KEYUP,
    		VK_DOWN,
    		0
    		);
    
    
    
    
    
    	HWND	SoundGrandChildHandle;
    	if ( ( SoundGrandChildHandle = FindWindowEx (
    		SoundChildHandle,
    		NULL,
    		L"Button",
    		L"&Properties"
    		) ) == NULL ) {
    			printf (
    				"Failed to Find Sounds Dialog GrandChild Window Exiting\n"
    				);
    			return 0;
    	}
    
    	printf (
    		"Found Sound Dialog GrandChild Window Properties Button HWND is %x\n",
    		SoundGrandChildHandle
    		);
    
    	SetFocus(SoundGrandChildHandle);
    
    	//sending alt+p to raise the properies window
    
    	PostMessage(
    		SoundGrandChildHandle,
    		WM_KEYDOWN,
    		VK_MENU,
    		0x181C0001
    		);
    	PostMessage(
    		SoundGrandChildHandle,
    		WM_CHAR,
    		'p',
    		0xC81C0001
    		);
    
    	// oh sleepyhead again to wait for the properties dialog to appear
    
    	Sleep(5000);
    
    	HWND	SpeakerDialogHandle;
    	if ( ( SpeakerDialogHandle = FindWindow (
    		L"#32770",
    		L"Speakers Properties"
    		) ) == NULL ) {
    			printf (
    				"Failed to Find Speakers properties Dialog Window Exiting\n"
    				);
    			return 0;
    	}
    
    	printf (
    		"Found Speakers Properties Dialog Window HWND is %x\n",
    		SpeakerDialogHandle
    		);
    
    	SetFocus(SpeakerDialogHandle);
    
    	HWND	SpeakerChildHandle;
    	if ( ( SpeakerChildHandle = FindWindowEx (
    		SpeakerDialogHandle,
    		NULL,
    		L"#32770",
    		L""
    		) ) == NULL ) {
    			printf (
    				"Failed to Find Speaker Child Dialog Window Exiting\n"
    				);
    			return 0;
    	}
    
    	printf (
    		"Found Speaker Dialog Child Window HWND is %x\n",
    		SpeakerChildHandle
    		);
    
    	SetFocus(SpeakerChildHandle);
    
    
    	HWND	SpeakerGrandChildHandle;
    	if ( ( SpeakerGrandChildHandle = FindWindowEx (
    		SpeakerChildHandle,
    		NULL,
    		L"ComboBox",
    		L""
    		) ) == NULL ) {
    			printf (
    				"Failed to Find Speaker GrandChild ComboBox Dialog Window Exiting\n"
    				);
    			return 0;
    	}
    
    	printf (
    		"Found Speaker Dialog GrandChild ComboBox Window HWND is %x\n",
    		SpeakerGrandChildHandle
    		);
    
    	SetFocus(SpeakerGrandChildHandle);
    
    	//disabling the Speaker
    
    	if (Disable == 1) {
    
    		PostMessage(
    			SpeakerGrandChildHandle,
    			WM_KEYDOWN,
    			VK_DOWN,
    			0
    			);
    		PostMessage(
    			SpeakerGrandChildHandle,
    			WM_KEYUP,
    			VK_DOWN,
    			0
    			);
    		PostMessage(
    			SpeakerGrandChildHandle,
    			WM_KEYDOWN,
    			VK_RETURN,
    			0
    			);
    		PostMessage(
    			SoundsDialogHandle,
    			WM_CLOSE,
    			NULL,
    			0
    			);
    	}
    	//enabling the speaker
    
    	else if (Disable == 2) {
    
    		PostMessage(
    			SpeakerGrandChildHandle,
    			WM_KEYDOWN,
    			VK_UP,
    			0
    			);
    		PostMessage(
    			SpeakerGrandChildHandle,
    			WM_KEYUP,
    			VK_UP,
    			0
    			);
    		PostMessage(
    			SpeakerGrandChildHandle,
    			WM_KEYDOWN,
    			VK_RETURN,
    			0
    			);
    		PostMessage(
    			SoundsDialogHandle,
    			WM_CLOSE,
    			NULL,
    			0
    			);
    	}
    
    
    
    
    
    	return 0;
    }
    
    

    c:\Users\test\Desktop>disablesound.exe
    e
    Found Sound Dialog HWND is 1a01b4
    Found Sound Dialog Child Window PlayBack HWND is 3101e6
    Found Sound Dialog GrandChild First Window Properties Button HWND is 5c0188
    Found Sound Dialog GrandChild Window Properties Button HWND is 10014e
    Found Speakers Properties Dialog Window HWND is 490240
    Found Speaker Dialog Child Window HWND is 4e0194
    Found Speaker Dialog GrandChild ComboBox Window HWND is 740202
    
    c:\Users\test\Desktop>disablesound.exe
    d
    Found Sound Dialog HWND is 1201fc
    Found Sound Dialog Child Window PlayBack HWND is 3201e6
    Found Sound Dialog GrandChild First Window Properties Button HWND is 5001ae
    Found Sound Dialog GrandChild Window Properties Button HWND is 1401e4
    Found Speakers Properties Dialog Window HWND is 4a0240
    Found Speaker Dialog Child Window HWND is 4f0194
    Found Speaker Dialog GrandChild ComboBox Window HWND is 3701ee
    
    c:\Users\test\Desktop>disablesound.exe
    r
    enter d or e only
    enter d or e only
    t
    enter d or e only
    enter d or e only
    e
    Found Sound Dialog HWND is 2201a8
    Found Sound Dialog Child Window PlayBack HWND is 520228
    Found Sound Dialog GrandChild First Window Properties Button HWND is 3301e6
    Found Sound Dialog GrandChild Window Properties Button HWND is 5101ae
    Found Speakers Properties Dialog Window HWND is 12014e
    Found Speaker Dialog Child Window HWND is 16015c
    Found Speaker Dialog GrandChild ComboBox Window HWND is 3a027c
    
    c:\Users\test\Desktop>

    • Proposed as answer by blufferisme Monday, April 23, 2012 11:36 PM
    Monday, April 23, 2012 10:51 PM
  • here is a package that contains source a precompiled binary and a bat file to compile and link it from vc 2008 express commandprompt

    https://sites.google.com/site/ulongbluff/bluffing-with-win7-sounds-applet


    • Edited by blufferisme Monday, April 23, 2012 11:48 PM
    Monday, April 23, 2012 11:47 PM
  • Good grief!

    That was not at all simple and I sure do appreciate the help.

    My Visual C++ 2008 Express Edition would not compile the source code (it complaints about errors in stdafx.h).  So, I tried to download the.exe but, for some reason, both Internet Explorer and Firefox refused to download anything but the .cpp file (i.e. they didn't allow access to either the .CMD or the .exe file.)

    In the full spirit of "No Good Deed Goes Unpunished" if you could rename the executable to something like .XEX the browser will probably allow me to download it.

    On a sour note:

    I find it offensive that Microsoft in its paternalism or arrogance has seen fit to hide the API call which, I am quite certain exists and, is probably the only thing done when the context menu items enable/disable are clicked.  Perhaps I am too sensitive.

    Thanks much again for your extensive effort,

     


    Steve Behman

    Tuesday, April 24, 2012 2:51 PM
  • it may complain about stdafx etc if you use the cpp in a project and use build (viz f7) do not use projects

    compile it from commandline

    open the command prompt in visual c++

    start->programs -> msvc++2008 express->visual studio tools -> visual studio command prompt

    navigate to the folder where you have the disablesound.cpp

    and type in

    cl disablesound.cpp

    it should compile if you have the sdk installed

    C:\Program Files\Microsoft SDKs\Windows\v7.1\include;

    it will complain about unresolved external symbols if you dont have sdks installed

    if you have sdks installed  and it is still complaining about unresolved external symbol it may not be in path / not accessible because you haven't integrated the sdk with vc  in which case do

    start->programs->microsoft sdk 7.1->visual studio registration -> windows sdk configuartion tool and follow the wizard

    Tuesday, April 24, 2012 9:31 PM
  • since it was a rar package and you say you can only get the cpp and not exe i think your av / blah blah / sandbox/ whatever is extracting the package and selectively stopping executable files from being downloaed

    so instead of renaming (a non stupid sandbox /whatever shouldn't rely on extensions alone is what i believe)

    i passworded the package

    the password is stated below the animated png that i added to the page 

    please use the same link posted two posts above

    Thursday, April 26, 2012 5:26 PM