1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69:
| procedure TMainform.Button1Click(Sender: TObject); var wnd : HWND; AnzahlIcons : integer; Schleife : integer; pID : cardinal; hProg : THandle; pAdr : Pointer; Gelesen : cardinal; AnzahlBytes : integer; Buffer : array [0..255] of char; begin wnd := FindWindow('Shell_TrayWnd', nil); wnd := FindWindowEx(wnd, 0, 'TrayNotifyWnd', nil); wnd := FindWindowEx(wnd, 0, 'SysPager', nil); wnd := FindWindowEx(wnd, 0, 'ToolbarWindow32', nil);
if wnd <> 0 then begin AnzahlIcons := SendMessage(wnd, TB_ButtonCount, 0, 0);
GetWindowThreadProcessID(wnd, @pID);
hProg := OpenProcess(Process_VM_Operation or Process_VM_Read or Process_VM_Write, false, pID);
AnzahlBytes := 255; pAdr := VirtualAllocEx(hProg, nil, AnzahlBytes, MEM_Reserve or MEM_Commit, Page_ReadWrite);
for Schleife := AnzahlIcons - 1 downto 0 do begin SendMessage(wnd, TB_GetButtonText, Schleife, integer(pAdr));
ReadProcessMemory(hProg, pAdr, @Buffer, AnzahlBytes, Gelesen);
if Pos('Lautsprecher', Buffer) > 0 then if Pos('%', Buffer) > 0 then Label1.Caption := 'Soundausgabe aktiv.' else Label1.Caption := 'Soundausgabe nicht aktiv.'; end;
VirtualFreeEx(hProg, pAdr, 0, MEM_Release);
CloseHandle(hProg); end; end; |