delphi – 如何获取通知区域图标的工具提示?
发布时间:2020-12-15 10:12:56 所属栏目:大数据 来源:网络整理
导读:我可以在通知区域中使用图标枚举应用程序(句柄,pid,路径),我可以控制图标的位置,但我无法获得工具提示. 如何枚举包含工具提示的系统托盘图标? 解决方法 这是我用windows xp和delphi 2010测试的方法,如果你使用的是delphi版本,不支持unicode make shure你将
我可以在通知区域中使用图标枚举应用程序(句柄,pid,路径),我可以控制图标的位置,但我无法获得工具提示.
如何枚举包含工具提示的系统托盘图标? 解决方法
这是我用windows xp和delphi 2010测试的方法,如果你使用的是delphi版本,不支持unicode make shure你将字符串读取转换为ansi
uses CommCtrl; function TForm1.GetIconsCount: Integer; begin Result := SendMessage(FindTrayToolbar,TB_BUTTONCOUNT,0); end; procedure TForm1.Button1Click(Sender: TObject); begin ListTips; end; function TForm1.FindTrayToolbar: HWND; begin Result := FindWindow('Shell_TrayWND',nil); Result := FindWindowEx(Result,'TrayNotifyWnd','SysPager','ToolbarWindow32',nil); end; procedure TForm1.ListTips; var dwTray: DWORD; wndTray: HWND; hTray: THandle; remoteTray: Pointer; tdata: TTBBUTTON; i: Integer; btsread:DWORD; str:Pchar; begin wndTray := FindTrayToolbar; GetWindowThreadProcessId(wndTray,@dwTray); hTray := OpenProcess(PROCESS_ALL_ACCESS,false,dwTray); if hTray <> 0 then begin remoteTray := VirtualAllocEx(hTray,nil,Sizeof(tdata),MEM_COMMIT,PAGE_READWRITE); for i := 0 to GetIconsCount - 1 do begin SendMessage(FindTrayToolbar,TB_GETBUTTON,wparam(i),lparam(remotetray)); ReadProcessMemory(hTray,remotetray,@tdata,sizeof(tdata),btsread); GetMem(str,255); ReadProcessMemory(hTray,Ptr(tdata.iString),str,255,btsread); ListBox1.Items.Add(str); end; end else ShowMessage('Could not locate tray icons'); end; end. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |