程序运行后未能实现隐藏功能,请大家帮忙看看问题出在哪,在下新手,谢谢!!!unit tray;interfaceuses
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.
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.
解决方案 »
- 求助高手:點擊DBGrid中CELL下面的下拉框觸發什麼事件?分不够多,再开帖!!!
- 请问如何能知道键盘按了ctrl+alt+a按键啊,有例子吗
- 请求帮忙噢,有什么办法实现异地两个数据库同步?
- tdxpageControlForD7不能同cxGrid一起安装?
- 请教备份恢复的问题,100分,不够再给
- delphi 7 使用问题
- 做一个拖拽程序,想同时接收,timage和tlabel,如何实现?
- 什么组件能将数据表中的某一字段的所有记录列出来?就这么简单。
- 如何捕捉ECONVERTERROR?ECONVERTERROR是什么类型?
- 急!急!急!工资存折打印问题??
- D2011
- 初学Delphi 想要快点上手
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);