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. setting active audio output vista [modified]

setting active audio output vista [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
comquestion
8 Posts 3 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.
  • S Offline
    S Offline
    Snoepie
    wrote on last edited by
    #1

    :confused: i am trying to adapt http://www.codeproject.com/KB/system/AudioConfigurationManager.aspx to work under vista sp2. Having it all running except for the interaction with the applet's button's using i can't get it to supply me with information. This code part gives me a headache: ZeroMemory(&lvItem,sizeof(LVITEM)); ZeroMemory(&lState,0,sizeof(LVITEM)); ZeroMemory(&item,512); defaultButton = handAcq->findChildWindow(appletWindow,BUTTON,DEFAULT_BUTTON); listView = handAcq->findChildWindow(appletWindow,COMBO_BOX,NULL); GetWindowThreadProcessId(listView,&procID); HANDLE lView=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION,false,procID); if (lView) { LVITEM *_lvi=(LVITEM*)VirtualAllocEx(lView, NULL, sizeof(LVITEM),MEM_COMMIT, PAGE_READWRITE); char *_item=(char*)VirtualAllocEx(lView, NULL, 512, MEM_COMMIT, PAGE_READWRITE); lvi.cchTextMax=512; lvi.pszText=_item; _lvi->stateMask= (UINT)-1; _lvi->mask=LVIF_STATE; if (applyButton && defaultButton) //found buttons { // THIS DOESN'T WORK, RETURNS AN EMPTY lvitem STRUCTURE SendMessage(listView, LVM_GETITEMSTATE, (WPARAM)0, (LPARAM)_lvi); ReadProcessMemory(lView, _lvi, &lState, sizeof(LVITEM), NULL); // THIS WORKS AND RETURNS THE ITEM NAMES SendMessage(listView, LVM_GETITEMTEXT, (WPARAM)0, (LPARAM)_lvi); ReadProcessMemory(lView, _item, item, 512, NULL); } There are no errors, just ignores any interaction with the applet other then retrieving strings. What am i doing wrong?

    modified on Saturday, April 25, 2009 9:02 AM

    Y S 2 Replies Last reply
    0
    • S Snoepie

      :confused: i am trying to adapt http://www.codeproject.com/KB/system/AudioConfigurationManager.aspx to work under vista sp2. Having it all running except for the interaction with the applet's button's using i can't get it to supply me with information. This code part gives me a headache: ZeroMemory(&lvItem,sizeof(LVITEM)); ZeroMemory(&lState,0,sizeof(LVITEM)); ZeroMemory(&item,512); defaultButton = handAcq->findChildWindow(appletWindow,BUTTON,DEFAULT_BUTTON); listView = handAcq->findChildWindow(appletWindow,COMBO_BOX,NULL); GetWindowThreadProcessId(listView,&procID); HANDLE lView=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION,false,procID); if (lView) { LVITEM *_lvi=(LVITEM*)VirtualAllocEx(lView, NULL, sizeof(LVITEM),MEM_COMMIT, PAGE_READWRITE); char *_item=(char*)VirtualAllocEx(lView, NULL, 512, MEM_COMMIT, PAGE_READWRITE); lvi.cchTextMax=512; lvi.pszText=_item; _lvi->stateMask= (UINT)-1; _lvi->mask=LVIF_STATE; if (applyButton && defaultButton) //found buttons { // THIS DOESN'T WORK, RETURNS AN EMPTY lvitem STRUCTURE SendMessage(listView, LVM_GETITEMSTATE, (WPARAM)0, (LPARAM)_lvi); ReadProcessMemory(lView, _lvi, &lState, sizeof(LVITEM), NULL); // THIS WORKS AND RETURNS THE ITEM NAMES SendMessage(listView, LVM_GETITEMTEXT, (WPARAM)0, (LPARAM)_lvi); ReadProcessMemory(lView, _item, item, 512, NULL); } There are no errors, just ignores any interaction with the applet other then retrieving strings. What am i doing wrong?

      modified on Saturday, April 25, 2009 9:02 AM

      Y Offline
      Y Offline
      Yovav
      wrote on last edited by
      #2

      Hi, The other day I just figured out the Vista has different interface for accessing mixers (volume controls) because of new security restrictions it only allow your application to see stuff in your level, In other words - you can only set / select the audio channel that your application is using, Look at this: IAudioEndpointVolume Interface[^]

      Best Regards - Yovav Gad CEO and founder of MicroMighty, Inc.

      S 1 Reply Last reply
      0
      • Y Yovav

        Hi, The other day I just figured out the Vista has different interface for accessing mixers (volume controls) because of new security restrictions it only allow your application to see stuff in your level, In other words - you can only set / select the audio channel that your application is using, Look at this: IAudioEndpointVolume Interface[^]

        Best Regards - Yovav Gad CEO and founder of MicroMighty, Inc.

        S Offline
        S Offline
        Snoepie
        wrote on last edited by
        #3

        Tnx for the input, i've already given up on using the Directx SDK. That's why i took the workaround, by calling the sound applet and just manipulating the message queue. I want to toggle the Realtek HD Audio between the speaker and digital output by code. Just read the itemstrings, see if they have a image state mask and move the cursor to the other one and push the setdefault button. The kludge given by http://www.codeproject.com/Members/odlumb for xp works in xp, just under vista the applet doesn't respond

        1 Reply Last reply
        0
        • S Snoepie

          :confused: i am trying to adapt http://www.codeproject.com/KB/system/AudioConfigurationManager.aspx to work under vista sp2. Having it all running except for the interaction with the applet's button's using i can't get it to supply me with information. This code part gives me a headache: ZeroMemory(&lvItem,sizeof(LVITEM)); ZeroMemory(&lState,0,sizeof(LVITEM)); ZeroMemory(&item,512); defaultButton = handAcq->findChildWindow(appletWindow,BUTTON,DEFAULT_BUTTON); listView = handAcq->findChildWindow(appletWindow,COMBO_BOX,NULL); GetWindowThreadProcessId(listView,&procID); HANDLE lView=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION,false,procID); if (lView) { LVITEM *_lvi=(LVITEM*)VirtualAllocEx(lView, NULL, sizeof(LVITEM),MEM_COMMIT, PAGE_READWRITE); char *_item=(char*)VirtualAllocEx(lView, NULL, 512, MEM_COMMIT, PAGE_READWRITE); lvi.cchTextMax=512; lvi.pszText=_item; _lvi->stateMask= (UINT)-1; _lvi->mask=LVIF_STATE; if (applyButton && defaultButton) //found buttons { // THIS DOESN'T WORK, RETURNS AN EMPTY lvitem STRUCTURE SendMessage(listView, LVM_GETITEMSTATE, (WPARAM)0, (LPARAM)_lvi); ReadProcessMemory(lView, _lvi, &lState, sizeof(LVITEM), NULL); // THIS WORKS AND RETURNS THE ITEM NAMES SendMessage(listView, LVM_GETITEMTEXT, (WPARAM)0, (LPARAM)_lvi); ReadProcessMemory(lView, _item, item, 512, NULL); } There are no errors, just ignores any interaction with the applet other then retrieving strings. What am i doing wrong?

          modified on Saturday, April 25, 2009 9:02 AM

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          snoepie wrote:

          SendMessage(defaultButton, LVM_GETITEMSTATE, (WPARAM)0, (LPARAM)_lvi);

          Something called 'defaultButton' is a list view? Either you've got the wrong control, or your naming convention is...very, very odd! :-) Judging by the call afterwards, you've got the wrong control

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          S 2 Replies Last reply
          0
          • S Stuart Dootson

            snoepie wrote:

            SendMessage(defaultButton, LVM_GETITEMSTATE, (WPARAM)0, (LPARAM)_lvi);

            Something called 'defaultButton' is a list view? Either you've got the wrong control, or your naming convention is...very, very odd! :-) Judging by the call afterwards, you've got the wrong control

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

            S Offline
            S Offline
            Snoepie
            wrote on last edited by
            #5

            blindingly obvious stupid mistake on my part.:~ Read over it a 1000 times. Stupid me, tnx. It's just so enormously frustrating to get a simple task done i've lost track

            1 Reply Last reply
            0
            • S Stuart Dootson

              snoepie wrote:

              SendMessage(defaultButton, LVM_GETITEMSTATE, (WPARAM)0, (LPARAM)_lvi);

              Something called 'defaultButton' is a list view? Either you've got the wrong control, or your naming convention is...very, very odd! :-) Judging by the call afterwards, you've got the wrong control

              Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

              S Offline
              S Offline
              Snoepie
              wrote on last edited by
              #6

              updated source code. same effect unfortunately :mad:

              S 1 Reply Last reply
              0
              • S Snoepie

                updated source code. same effect unfortunately :mad:

                S Offline
                S Offline
                Stuart Dootson
                wrote on last edited by
                #7

                Looking in your original code, you attempt to initialise the LVITEM @ _lvi using these two lines:

                _lvi->stateMask= (UINT)-1;
                _lvi->mask=LVIF_STATE;

                but that memory is in a different process! I think you need to use WriteProcessMemory to do that? I just tried your code and my process crashed, probably because the address that _lvi refers to wasn't allocated in my progrm (but it is in yours?).

                Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                S 1 Reply Last reply
                0
                • S Stuart Dootson

                  Looking in your original code, you attempt to initialise the LVITEM @ _lvi using these two lines:

                  _lvi->stateMask= (UINT)-1;
                  _lvi->mask=LVIF_STATE;

                  but that memory is in a different process! I think you need to use WriteProcessMemory to do that? I just tried your code and my process crashed, probably because the address that _lvi refers to wasn't allocated in my progrm (but it is in yours?).

                  Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                  S Offline
                  S Offline
                  Snoepie
                  wrote on last edited by
                  #8

                  bingo! needed just a fresh eye. Been at it for more then a week now. Started with directx to find out the obvious and finally hooked up with this kludge. Works fine now. I'll upload the finished code when done as an addition to the XP version. Added commandline switches for toggling

                  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