//types
type
TTBBUTTON = packed record // 20
iBitmap: Integer;
idCommand: Integer;
fsState: Byte;
fsStyle: Byte;
bReserved: array[1..2] of Byte;
dwData: Longint;
iString: Integer;
end;
PTNAEntry = ^TTNAEntry;
TTNAEntry = record
hwnd: Cardinal;
uID: Integer;
uCallbackMessage: Cardinal;
Unknwon1: Array[0..1] of Cardinal;
hIcon: Cardinal;
Unknwon2: Array[0..2] of Cardinal;
uniPath: string;
sTip: string;
iBitmap: Cardinal;
idCommand: Integer;
fsState: byte;
fsStyle: byte;
dwData: Cardinal;
iString: Cardinal;
end;
TTNAEntryArr = Array of TTNAEntry;
// funcs
function GetTNAEntries(): TTNAEntryArr;
var
but: TTBBUTTON;
hWnd, PID,
hProc: Cardinal;
MEM: Pointer;
Count: Cardinal;
x: Cardinal;
i: Integer;
buf: WideChar;
p: PWideChar;
const
TB_GETBUTTON = WM_USER+$17; //23;
TB_BUTTONCOUNT = WM_USER+$18; //24;
begin
hWnd := FindWindowEx( FindWindowEx( FindWindowEx( FindWindow('Shell_TrayWnd',0), 0, 'TrayNotifyWnd', 0 ), 0, 'SysPager', 0 ), 0, 'ToolbarWindow32', 0 );
GetWindowThreadProcessID( hWnd, @PID );
try
hProc := OpenProcess( PROCESS_ALL_ACCESS, False, PID );
MEM := VirtualAllocEx( hProc, nil, SizeOf(TTBButton), MEM_COMMIT, PAGE_EXECUTE_READWRITE );
Count := SendMessage( hWnd, TB_BUTTONCOUNT, 0, 0 );
SetLength(Result, Count);
for i := 0 to Count - 1 do
begin
SendMessage( hWnd, TB_GETBUTTON, i, integer(MEM) );
ReadProcessMemory( hProc, MEM, @but, SizeOf(TTBBUTTON), x );
Move( but, Result[i].hwnd, sizeof(but) );
if but.iString > 0 then
begin
p := Pointer(but.iString);
repeat
ReadProcessMemory( hProc, p, @buf, 2, x );
inc(p);
Result[i].sTip := Result[i].sTip + buf;
until buf = #0;
end;
ReadProcessMemory( hProc, Pointer(but.dwData), @result[i].hwnd, 36, x );
end;
finally
VirtualFreeEx( hProc, MEM, SizeOf(TTBButton), MEM_DECOMMIT );
CloseHandle( hProc );
end;
end;