1,183
社区成员
发帖
与我相关
我的任务
分享
function TrayHWnd: HWND;
var
h,hTmp: HWND;
begin
h := FindWindow('Shell_TrayWnd', nil);
h := FindWindowEx(h, 0, 'TrayNotifyWnd', nil);
hTmp := FindWindowEx(h, 0, 'SysPager', nil);
if hTmp <> 0 then h := hTmp;
hTmp := FindWindowEx(h, 0, 'ToolbarWindow32', nil);
if hTmp <> 0 then h := hTmp;
Result := h;
end;
{提取列表}
procedure TForm1.Button1Click(Sender: TObject);
var
h: HWND;
count,size,num: Cardinal;
pid, ph: Cardinal;
p: Pointer;
icoBtn: TTBButton;
buf: array[0..255] of WideChar;
i: Integer;
item: TListItem;
begin
h := TrayHWnd;
count := SendMessage(h, TB_BUTTONCOUNT, 0, 0);
size := SizeOf(TTBButton);
GetWindowThreadProcessId(h, pid);
ph := OpenProcess(PROCESS_VM_READ, False, pid);
for i := 0 to count - 1 do
begin
SendMessage(h, TB_GETBUTTON, i, DWORD(p));
ReadProcessMemory(ph, p, @icoBtn, size, num);
ReadProcessMemory(ph, Pointer(icoBtn.iString), @buf, Length(buf)*SizeOf(buf[0]), num);
item := ListView1.Items.Add;
item.Caption := buf;
end;
CloseHandle(ph);
Button2.Enabled := True;
Button3.Enabled := True;
end;