隐藏托盘图标的问题

qpqpqpqp 2010-04-07 10:49:49
程序运行后未能实现隐藏功能,请大家帮忙看看问题出在哪,在下新手,谢谢!!!

unit tray;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
//procedure FormCreate(Sender: TObject);
procedure enumTrayNotifyWnd;
private

public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

uses Commctrl;


procedure TForm1.enumTrayNotifyWnd;
var
wd:HWND;
wtd:HWND;
wd1:HWND;
pid:DWORD;
hd:THandle;
num,i:integer;
n:ULONG;

x:string;
name :array[0..255] of WCHAR;
whd,proid :ulong;
temp :string;
sp:^TTBBUTTON;
_sp:TTBBUTTON;//结构体

pp:^TTBBUTTON;
p:TTBBUTTON;

begin
wd:=FindWindow('Shell_TrayWnd',nil); //寻找父窗口
if (wd=0) then
begin
showmessage('Error1');
exit;
end;
wtd:=FindWindowEx(wd,0,'TrayNotifyWnd',nil); //右下角任务栏
if (wtd=0) then
begin
showmessage('Error2');
exit;
end;

wtd:=FindWindowEx(wtd,0,'SysPager',nil); //主要显示栏
if (wtd=0) then
begin
showmessage('SysPager');
exit;
end;

wd1:=FindWindowEx(wtd,0,'ToolbarWindow32',nil);//图标区
if (wd1=0) then
begin
showmessage('Error3');
exit;
end;

pid:=0;
GetWindowThreadProcessId(wd1,@pid);//返回进程 ID 的指针
if (pid=0) then
begin
showmessage('Error4');
exit;
end;

hd:=OpenProcess(PROCESS_ALL_ACCESS ,true,pid);//返回进程的句柄
if (hd=0) then
begin
showmessage('Error6'#13+ IntToStr(hd));
exit;
end;

num:=SendMessage(wd1,TB_BUTTONCOUNT,0,0);//获取图标个数

sp:=@_sp;//sp是指针
for i:= 0 to num do
begin
SendMessage(wd1,TB_GETBUTTON,i,integer(sp));//integer强制类型转换

pp:=@p;
ReadProcessMemory(hd,sp,pp,sizeof(p),n);
//x:=Format('%x %x %x %x %x %x ',[p.iBitmap,p.idCommand,p.fsState,p.fsStyle,p.dwData,p.iString]);


name[0]:=char(0);
if (Cardinal(p.iString) <>$ffffffff) then
begin
try
ReadProcessMemory(hd,pointer(p.iString),@name,255,n);
name[n]:=char(0);
except
showmessage('except1')
end;
temp:=name;
try
whd:=0;
ReadProcessMemory(hd,pointer(p.dwData),@whd,4,n);
except
end;

proid:=0;
GetWindowThreadProcessId(whd,@proid);
x:=x+#13+Format('位置=%d 名称=%s 窗口句柄=%x 进程ID=%x',[i,temp,whd,proid]);
end;
end;
ShowMessage(x);
end;

end.
...全文
246 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
foodztf 2010-05-03
  • 打赏
  • 举报
回复
不好整
hongss 2010-04-27
  • 打赏
  • 举报
回复

SendMessage(wd1,TB_GETBUTTON,i,integer(sp));//integer强制类型转换
pp:=@p;
ReadProcessMemory(hd,sp,pp,sizeof(p),n);
//x:=Format('%x %x %x %x %x %x ',[p.iBitmap,p.idCommand,p.fsState,p.fsStyle,p.dwData,p.iString]);
name[0]:=char(0);
if i=1 then //排列在第一个的托盘图标隐藏(你需要隐藏的托盘图标的特征)
SendMessage(wd1, TB_DELETEBUTTON, i, 0);
Frank.WU 2010-04-27
  • 打赏
  • 举报
回复
用CNVCL的例子吧。
Frank.WU 2010-04-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 kayewhokai 的回复:]

用TRAYICON控件,设置几个简单属性即可图标到系统托盘区·~~
[/Quote]
这位同学,人家问的是如何隐藏别的程序的托盘区图标。。。
kayewhokai 2010-04-22
  • 打赏
  • 举报
回复
用TRAYICON控件,设置几个简单属性即可图标到系统托盘区·~~
qpqpqpqp 2010-04-08
  • 打赏
  • 举报
回复
哦,我是没有调用编写的过程,回去再试试。
SQLDebug_Fan 2010-04-08
  • 打赏
  • 举报
回复
楼主是要隐藏别的程序的图标?

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧