如何获取通知区域图标的工具提示? [英] How can I get the tooltips of notification-area icons?

查看:247
本文介绍了如何获取通知区域图标的工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用通知区域中的图标枚举应用程序(handle,pid,path),我可以控制图标的位置,但是我无法获取工具提示。

I can enumerate the applications (handle,pid,path) with icons in the notification area, and I can control the position of the icons, but I can't get the tooltip.

如何枚举系统管理员图标,包括工具提示?

How can I enumerate systray icons including the tooltips?

推荐答案

这是我的方法,用windows xp和delphi 2010,如果你使用的是一个版本的delphi,它不支持unicode make shure你将读取的字符串转换成ansi

Here is my method tested with windows xp and delphi 2010 if you are using a version of delphi wich doesn't support unicode make shure you convert the strings read to ansi

uses CommCtrl;

function TForm1.GetIconsCount: Integer;
begin
  Result := SendMessage(FindTrayToolbar, TB_BUTTONCOUNT, 0, 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    ListTips;
end;

function TForm1.FindTrayToolbar: HWND;
begin
  Result := FindWindow('Shell_TrayWND', nil);
  Result := FindWindowEx(Result, 0, 'TrayNotifyWnd', nil);
  Result := FindWindowEx(Result, 0, 'SysPager', nil);
  Result := FindWindowEx(Result, 0, '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.

这篇关于如何获取通知区域图标的工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆