delphi 获取系统托盘程序列表


本文整理自网络,侵删。

 
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.

相关阅读 >>

Delphi idhttp基本使用方法

Delphi record,两种声明方式

Delphi richedit的实现msn / qq 中的动画表情

tstrings 的用法

Delphi android gps服务

Delphi xe安装后配置android的sdk的方法

Delphi 限制窗体大小的最大值与最小值

Delphi的流操作的语法

Delphi定时器相关的简单例子

Delphi 取得当前监视器的分辨率

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...