|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
突然想到又添加一个把“疯狂刷新”的托盘图标都隐藏的功能。于是百度了半天才弄到一个还可以的实现功能。
(添加uses CommCtrl;)
[url=]procedure[/url] HideAllTrace;
[url=]var[/url] TBHWND: [url=]HWND[/url];
i, count: [url=]Integer[/url];
PID, PRC: THandle;
Buff: [url=]PChar[/url];
Info: _TBBUTTON;
R: [url=]Cardinal[/url];
S: [url=]array[/url][0..1024] [url=]of[/url] [url=]char[/url];
[url=]begin[/url]
TBHWND := GetSysTrayWnd;
[url=]if[/url] TBHWND = 0 [url=]then[/url] exit;
[url=]GetWindowThreadProcessId[/url](TBHWND, @PID);
PRC := [url=]OpenProcess[/url](PROCESS_VM_OPERATION [url=]or[/url] PROCESS_VM_READ [url=]or[/url] PROCESS_VM_WRITE, [url=]False[/url], PID);
Buff := [url=]VirtualAllocEx[/url](PRC, [url=]nil[/url], 4096, MEM_RESERVE [url=]or[/url] MEM_COMMIT, PAGE_READWRITE);
count := [url=]SendMessage[/url](TBHWND, TB_BUTTONCOUNT, 0, 0); [url=]//托盘中button的个数,不一定是图标的个数,有些button是隐藏的。[/url]
[url=]for[/url] i := 0 [url=]to[/url] count - 1 [url=]do[/url]
[url=]begin[/url]
FillChar(Info, [url=]SizeOf[/url](Info), 0);
[url=]WriteProcessMemory[/url](PRC, Buff, @Info, [url=]SizeOf[/url](Info), R); [url=]//消息使用的内存空间必须在Shell之内,所以利用ReadProcessMemoery和WriteProcessMemory。[/url]
[url=]SendMessage[/url](TBHWND, TB_GETBUTTON, i, [url=]Integer[/url](Buff));
[url=]ReadProcessMemory[/url](PRC, Buff, @Info, [url=]SizeOf[/url](Info), R);
[url=]SendMessage[/url](TBHWND, TB_GETBUTTONTEXT, Info.idCommand, [url=]Integer[/url]([url=]Integer[/url](@Buff[0]) + [url=]SizeOf[/url](Info)));
[url=]ReadProcessMemory[/url](PRC, Pointer([url=]Integer[/url](@Buff[0]) + [url=]SizeOf[/url](Info)), @S[0], [url=]SizeOf[/url](S), R);
[url=]if[/url] pos([url=]'疯狂刷新'[/url], StrPas(S)) > 0 [url=]then[/url] [url=]//如果button的TEXT中包含'疯狂刷新'[/url]
[url=]SendMessage[/url](TBHWND, TB_DELETEBUTTON, i, 0); [url=]//删除[/url]
[url=]end[/url];
[url=]VirtualFreeEx[/url](PRC, Buff, 0, MEM_RELEASE);
[url=]CloseHandle[/url](PRC);
[url=]end[/url];
转帖自:http://www.delphitop.com/html/chengxu/1589.html
|
|
|