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