Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to disable the system speaker control

How to disable the system speaker control

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
23 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A ashwath2005

    Sorry,Mute and Unmute are working fine.I have written the following code to disable the mute control,but it is not working. MIXERCONTROL mc = {0}; mc.fdwControl=MIXERCONTROL_CONTROLF_DISABLED; Please Help.

    D Offline
    D Offline
    David Crow
    wrote on last edited by
    #5

    ashwath2005 wrote:

    Please Help.

    I'd like to but without knowing what those functions are returning, it's not possible.


    "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

    "There is no death, only a change of worlds." - Native American Proverb

    A 1 Reply Last reply
    0
    • D David Crow

      ashwath2005 wrote:

      Please Help.

      I'd like to but without knowing what those functions are returning, it's not possible.


      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

      "There is no death, only a change of worlds." - Native American Proverb

      A Offline
      A Offline
      ashwath2005
      wrote on last edited by
      #6

      hi, I have written the following code for disabling the MUTE control, MMRESULT result; HMIXER hMixer; result = mixerOpen(&hMixer, MIXER_OBJECTF_MIXER, 0, 0, 0); //obtain a handle to the mixer device. if(result!=MMSYSERR_NOERROR) { ::MessageBox(NULL,"Mixer could not be opened","1",MB_OK); } //we need to get the speaker line of the mixer device MIXERLINE ml = {0}; ml.cbStruct = sizeof(MIXERLINE); ml.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; result = mixerGetLineInfo((HMIXEROBJ) hMixer,&ml, MIXER_GETLINEINFOF_COMPONENTTYPE); if(result!=MMSYSERR_NOERROR) { ::MessageBox(NULL,"mixerGetLineInfo failed","1",MB_OK); } //we need to get the volume control of the speaker line. MIXERLINECONTROLS mlc = {0}; MIXERCONTROL mc={0}; mc.fdwControl=MIXERCONTROL_CONTROLF_DISABLED; mlc.cbStruct = sizeof(MIXERLINECONTROLS); mlc.dwLineID = ml.dwLineID; mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUTE; mlc.cControls = 1; mlc.pamxctrl = &mc; mlc.cbmxctrl = sizeof(MIXERCONTROL); result = mixerGetLineControls((HMIXEROBJ)hMixer, &mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE); if(result!=MMSYSERR_NOERROR) { ::MessageBox(NULL,"mixerGetLineControls failed","2",MB_OK); } //we set the mute and unmute values MIXERCONTROLDETAILS mcd = {0}; MIXERCONTROLDETAILS_UNSIGNED mcdu = {0}; mcdu.dwValue =lVal; //0 for unmute and //65535 for mute. mcd.cbStruct = sizeof(MIXERCONTROLDETAILS); mcd.hwndOwner = 0; mcd.dwControlID =mc.dwControlID; mcd.paDetails = &mcdu; mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED); mcd.cChannels = 1; result = mixerSetControlDetails((HMIXEROBJ)hMixer, &mcd, MIXER_SETCONTROLDETAILSF_VALUE); if(result!=MMSYSERR_NOERROR) { ::MessageBox(NULL,"mixerSetControlDetails failed","3",MB_OK); } The above code does not disable the MUTE control. I have checked all the return values,all of them return MMSYSERR_NOERROR as the return value. Kindly help me to fix this problem.

      D 1 Reply Last reply
      0
      • A ashwath2005

        hi, I have written the following code for disabling the MUTE control, MMRESULT result; HMIXER hMixer; result = mixerOpen(&hMixer, MIXER_OBJECTF_MIXER, 0, 0, 0); //obtain a handle to the mixer device. if(result!=MMSYSERR_NOERROR) { ::MessageBox(NULL,"Mixer could not be opened","1",MB_OK); } //we need to get the speaker line of the mixer device MIXERLINE ml = {0}; ml.cbStruct = sizeof(MIXERLINE); ml.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS; result = mixerGetLineInfo((HMIXEROBJ) hMixer,&ml, MIXER_GETLINEINFOF_COMPONENTTYPE); if(result!=MMSYSERR_NOERROR) { ::MessageBox(NULL,"mixerGetLineInfo failed","1",MB_OK); } //we need to get the volume control of the speaker line. MIXERLINECONTROLS mlc = {0}; MIXERCONTROL mc={0}; mc.fdwControl=MIXERCONTROL_CONTROLF_DISABLED; mlc.cbStruct = sizeof(MIXERLINECONTROLS); mlc.dwLineID = ml.dwLineID; mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUTE; mlc.cControls = 1; mlc.pamxctrl = &mc; mlc.cbmxctrl = sizeof(MIXERCONTROL); result = mixerGetLineControls((HMIXEROBJ)hMixer, &mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE); if(result!=MMSYSERR_NOERROR) { ::MessageBox(NULL,"mixerGetLineControls failed","2",MB_OK); } //we set the mute and unmute values MIXERCONTROLDETAILS mcd = {0}; MIXERCONTROLDETAILS_UNSIGNED mcdu = {0}; mcdu.dwValue =lVal; //0 for unmute and //65535 for mute. mcd.cbStruct = sizeof(MIXERCONTROLDETAILS); mcd.hwndOwner = 0; mcd.dwControlID =mc.dwControlID; mcd.paDetails = &mcdu; mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED); mcd.cChannels = 1; result = mixerSetControlDetails((HMIXEROBJ)hMixer, &mcd, MIXER_SETCONTROLDETAILSF_VALUE); if(result!=MMSYSERR_NOERROR) { ::MessageBox(NULL,"mixerSetControlDetails failed","3",MB_OK); } The above code does not disable the MUTE control. I have checked all the return values,all of them return MMSYSERR_NOERROR as the return value. Kindly help me to fix this problem.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #7

        ashwath2005 wrote:

        Kindly help me to fix this problem.

        What exactly are you expecting this code to do, disable the Mute all checkbox? If so, see here.


        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

        "There is no death, only a change of worlds." - Native American Proverb

        A 1 Reply Last reply
        0
        • D David Crow

          ashwath2005 wrote:

          Kindly help me to fix this problem.

          What exactly are you expecting this code to do, disable the Mute all checkbox? If so, see here.


          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

          "There is no death, only a change of worlds." - Native American Proverb

          A Offline
          A Offline
          ashwath2005
          wrote on last edited by
          #8

          Hi, I want the code to GRAY the "Mute all" Check box so that user does not have access to it.

          D 1 Reply Last reply
          0
          • A ashwath2005

            Hi, I want the code to GRAY the "Mute all" Check box so that user does not have access to it.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #9

            Then you'll need to get a handle to that control (id = 0x3e8) and call EnableWindow(FALSE).


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "There is no death, only a change of worlds." - Native American Proverb

            A 1 Reply Last reply
            0
            • D David Crow

              Then you'll need to get a handle to that control (id = 0x3e8) and call EnableWindow(FALSE).


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "There is no death, only a change of worlds." - Native American Proverb

              A Offline
              A Offline
              ashwath2005
              wrote on last edited by
              #10

              hi, How should i get the handle to the control.Which API should i use. Please Help Thanks, -- modified at 10:23 Tuesday 11th April, 2006

              D 1 Reply Last reply
              0
              • A ashwath2005

                hi, How should i get the handle to the control.Which API should i use. Please Help Thanks, -- modified at 10:23 Tuesday 11th April, 2006

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #11

                ashwath2005 wrote:

                How should i get the handle to the control.Which API should i use.

                Try FindWindow() and/or FindWindowEx().


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "There is no death, only a change of worlds." - Native American Proverb

                A 1 Reply Last reply
                0
                • D David Crow

                  ashwath2005 wrote:

                  How should i get the handle to the control.Which API should i use.

                  Try FindWindow() and/or FindWindowEx().


                  "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                  "There is no death, only a change of worlds." - Native American Proverb

                  A Offline
                  A Offline
                  ashwath2005
                  wrote on last edited by
                  #12

                  hi, I used the following code to GRAY the "Mute all" check box,but it is not working.Is there any other method. HWND hwnd1=::FindWindow(NULL,"Volume Control"); HWND hwnd=::GetDlgItem(hwnd1,0x3e8); ::EnableWindow(hwnd,FALSE);

                  D 1 Reply Last reply
                  0
                  • A ashwath2005

                    hi, I used the following code to GRAY the "Mute all" check box,but it is not working.Is there any other method. HWND hwnd1=::FindWindow(NULL,"Volume Control"); HWND hwnd=::GetDlgItem(hwnd1,0x3e8); ::EnableWindow(hwnd,FALSE);

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #13

                    ashwath2005 wrote:

                    I used the following code to GRAY the "Mute all" check box,but it is not working.

                    Your code snippet worked fine for me.

                    ashwath2005 wrote:

                    Is there any other method.

                    No. What you have will work.


                    "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                    "There is no death, only a change of worlds." - Native American Proverb

                    A 1 Reply Last reply
                    0
                    • D David Crow

                      ashwath2005 wrote:

                      I used the following code to GRAY the "Mute all" check box,but it is not working.

                      Your code snippet worked fine for me.

                      ashwath2005 wrote:

                      Is there any other method.

                      No. What you have will work.


                      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                      "There is no death, only a change of worlds." - Native American Proverb

                      A Offline
                      A Offline
                      ashwath2005
                      wrote on last edited by
                      #14

                      hi, I am using Windows XP machine.Which system are you using.May be it does not work on XP system.

                      A 1 Reply Last reply
                      0
                      • A ashwath2005

                        hi, I am using Windows XP machine.Which system are you using.May be it does not work on XP system.

                        A Offline
                        A Offline
                        ashwath2005
                        wrote on last edited by
                        #15

                        hi, It worked for me also ,but it works only when the "Volume Control" window is opened and then you execute the code snippet.What should happen is that even when the "Volume Control" window is closed and then you excute the code snippet,it should work.

                        D 1 Reply Last reply
                        0
                        • A ashwath2005

                          hi, It worked for me also ,but it works only when the "Volume Control" window is opened and then you execute the code snippet.What should happen is that even when the "Volume Control" window is closed and then you excute the code snippet,it should work.

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #16

                          ashwath2005 wrote:

                          ...but it works only when the "Volume Control" window is opened

                          Of course. What else would you expect? The Mute all checkbox does not exist otherwise.

                          ashwath2005 wrote:

                          What should happen is that even when the "Volume Control" window is closed and then you excute the code snippet,it should work.

                          Lots of luck to you. It's impossible to manipulate a window/control that does not exist.


                          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                          "There is no death, only a change of worlds." - Native American Proverb

                          A 1 Reply Last reply
                          0
                          • D David Crow

                            ashwath2005 wrote:

                            ...but it works only when the "Volume Control" window is opened

                            Of course. What else would you expect? The Mute all checkbox does not exist otherwise.

                            ashwath2005 wrote:

                            What should happen is that even when the "Volume Control" window is closed and then you excute the code snippet,it should work.

                            Lots of luck to you. It's impossible to manipulate a window/control that does not exist.


                            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                            "There is no death, only a change of worlds." - Native American Proverb

                            A Offline
                            A Offline
                            ashwath2005
                            wrote on last edited by
                            #17

                            hi, ok then is there a way to GRAY the volume control icon in the task bar.

                            D 1 Reply Last reply
                            0
                            • A ashwath2005

                              hi, ok then is there a way to GRAY the volume control icon in the task bar.

                              D Offline
                              D Offline
                              David Crow
                              wrote on last edited by
                              #18

                              Why would you even consider doing this? Do you not think that the user would be somewhat annoyed that they could not change the volume on their computer? How friendly would that be?


                              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                              "There is no death, only a change of worlds." - Native American Proverb

                              A 1 Reply Last reply
                              0
                              • D David Crow

                                Why would you even consider doing this? Do you not think that the user would be somewhat annoyed that they could not change the volume on their computer? How friendly would that be?


                                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                                "There is no death, only a change of worlds." - Native American Proverb

                                A Offline
                                A Offline
                                ashwath2005
                                wrote on last edited by
                                #19

                                hi, There is such a requirement in my project.I should do it. Could you help please.

                                D 1 Reply Last reply
                                0
                                • A ashwath2005

                                  hi, There is such a requirement in my project.I should do it. Could you help please.

                                  D Offline
                                  D Offline
                                  David Crow
                                  wrote on last edited by
                                  #20

                                  ashwath2005 wrote:

                                  There is such a requirement in my project.

                                  Just because it is a requirement does not make it a good idea. Please explain what you are doing and maybe we could could come up with an alternative solution that is more practical.

                                  ashwath2005 wrote:

                                  Could you help please.

                                  I just made eight posts to this thread. Don't you think I would have helped if I could? Do you think that I am purposely withholding information?


                                  "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                                  "There is no death, only a change of worlds." - Native American Proverb

                                  A 1 Reply Last reply
                                  0
                                  • D David Crow

                                    ashwath2005 wrote:

                                    There is such a requirement in my project.

                                    Just because it is a requirement does not make it a good idea. Please explain what you are doing and maybe we could could come up with an alternative solution that is more practical.

                                    ashwath2005 wrote:

                                    Could you help please.

                                    I just made eight posts to this thread. Don't you think I would have helped if I could? Do you think that I am purposely withholding information?


                                    "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                                    "There is no death, only a change of worlds." - Native American Proverb

                                    A Offline
                                    A Offline
                                    ashwath2005
                                    wrote on last edited by
                                    #21

                                    hi, In our project there is an option to Control the Volume of audio of the system,so when the user does control the volume through our software,he should not be allowed to go and change the volume through the system.

                                    A 1 Reply Last reply
                                    0
                                    • A ashwath2005

                                      hi, In our project there is an option to Control the Volume of audio of the system,so when the user does control the volume through our software,he should not be allowed to go and change the volume through the system.

                                      A Offline
                                      A Offline
                                      ashwath2005
                                      wrote on last edited by
                                      #22

                                      hi, Can i ask you a question.How did you get the id of the "Mute all" check box to be 0x3e8.

                                      D 1 Reply Last reply
                                      0
                                      • A ashwath2005

                                        hi, Can i ask you a question.How did you get the id of the "Mute all" check box to be 0x3e8.

                                        D Offline
                                        D Offline
                                        David Crow
                                        wrote on last edited by
                                        #23

                                        ashwath2005 wrote:

                                        How did you get the id of the "Mute all" check box to be 0x3e8.

                                        Spy++.


                                        "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                                        "There is no death, only a change of worlds." - Native American Proverb

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups