请问如何实现隐藏任务栏小图标?(150分)

  • 主题发起人 主题发起人 大唐电信
  • 开始时间 开始时间

大唐电信

Unregistered / Unconfirmed
GUEST, unregistred user!
各位老大:<br> &nbsp; &nbsp; &nbsp; &nbsp; 我想做一个隐藏任务栏上的某个小图标的程序,请给一些相关的方法?<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;谢谢!!
 
XP下的<br>function TForm1.f_ShowTrayIcon(p_Index: Integer; p_Show: Boolean): Boolean; <br>var <br> v_hShellTray: &nbsp;THandle; <br> v_hTrayNotify: THandle; <br> v_hToolBar: &nbsp; &nbsp;THandle; <br>begin <br> Result := True; <br> v_hShellTray := FindWindow('Shell_TrayWnd', nil); <br> if v_hShellTray &lt;&gt; 0 then <br> begin <br> &nbsp; v_hTrayNotify := FindWindowEx(v_hShellTray, 0, 'TrayNotifyWnd', nil); <br> &nbsp; if v_hTrayNotify &lt;&gt; 0 then <br> &nbsp; begin <br> &nbsp; &nbsp; v_hToolBar := FindWindowEx(v_hTrayNotify, 0, 'ToolbarWindow32', nil); <br> &nbsp; &nbsp; if v_hToolBar &lt;&gt; 0 then <br> &nbsp; &nbsp; begin <br> &nbsp; &nbsp; &nbsp; SendMessage(v_hToolBar, TB_HIDEBUTTON, p_Index, integer(not p_Show)); <br> &nbsp; &nbsp; end; <br> &nbsp; end; <br> end; <br>end;
 
procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> &nbsp;Application.Minimize;<br> &nbsp;ShowWindow(Handle, &nbsp;SW_HIDE);<br> &nbsp;ShowWindow(Application.Handle, SW_HIDE);<br> &nbsp;SetWindowLong(Application.Handle, GWL_EXSTYLE,GetWindowLong(Application.Handle, GWL_EXSTYLE)or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);<br>end;
 
可是我怎么知道图标的ID号乃?比如我想隐藏金山词霸的图标,我该怎么做?<br>也就是说我想获得任务栏的所有小图标及其相应的ID,以便显示在程序上,以后选择哪个就隐藏哪个。<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 谢谢
 
有现成的控件CoolTrayIcon,你搜一下就找到了。
 
不想用控件,想用API来实现。<br>各位老大:<br> &nbsp; &nbsp; &nbsp; &nbsp; 怎么才能得到任务栏上的图标啊?
 
强烈建议你去看看Big Aphex 的afxrootkit的源代码
 
忘了..是afxrootkit2005 ,2ccc上有下
 
这个是根据BCB改的 原帖见<br>http://topic.csdn.net/t/20050301/18/3816203.html<br>这里我只写出列举 不写删除<br><br>unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, CommCtrl, StdCtrls;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;Memo1: TMemo;<br> &nbsp; &nbsp;procedure FormCreate(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp; &nbsp;procedure f_ShowTrayIcon();<br> &nbsp;end;<br><br>var<br> &nbsp;Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.f_ShowTrayIcon();<br>var<br> &nbsp;hTrayWnd: THandle;<br> &nbsp;dwProcessID: DWORD;<br> &nbsp;hSourceHandle: THandle;<br> &nbsp;hTargetHandle: THandle;<br> &nbsp;pStart: Pointer;<br> &nbsp;pBufStart: Pointer;<br><br><br> &nbsp;Result : Integer;<br> &nbsp;dwAllocSize: DWORD;<br><br> &nbsp;ButtonCount: Integer;<br><br> &nbsp;v_Count: Integer;<br><br> &nbsp;v_Info: TBBUTTONINFO;<br> &nbsp;dwWrite,dwRead: DWORD;<br><br> &nbsp;TempBuf: PByte;<br>const<br> &nbsp;TextBufSize &nbsp; = &nbsp; 128;<br>begin<br> &nbsp;hTrayWnd &nbsp; := &nbsp; FindWindow('Shell_TrayWnd', nil);<br> &nbsp;hTrayWnd &nbsp; := &nbsp; FindWindowEx(hTrayWnd,0,'TrayNotifyWnd',nil);<br> &nbsp;hTrayWnd &nbsp; := &nbsp; FindWindowEx(hTrayWnd,0,'SysPager',nil); //&lt;--2000不要这个<br> &nbsp;hTrayWnd &nbsp; := &nbsp; FindWindowEx(hTrayWnd,0,'ToolbarWindow32',nil);<br><br> &nbsp;GetWindowThreadProcessId(hTrayWnd, @dwProcessID);<br><br> &nbsp;hSourceHandle &nbsp; := &nbsp; OpenProcess(PROCESS_ALL_ACCESS,false,dwProcessID);<br> &nbsp;if hSourceHandle = 1 then<br> &nbsp;begin<br> &nbsp; &nbsp;Memo1.Lines.Add('Error &nbsp; Open &nbsp; Process. &nbsp; Err=' + SysErrorMessage(GetLastError()));<br> &nbsp;end;<br><br> &nbsp;Result := Integer(DuplicateHandle(GetCurrentProcess(),hSourceHandle,GetCurrentProcess(),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@hTargetHandle,PROCESS_ALL_ACCESS,false,0));<br><br> &nbsp;if Result = 0 THEN<br> &nbsp;begin<br> &nbsp; &nbsp;Memo1.Lines.Add('Error &nbsp; Open &nbsp; Process. &nbsp; Err=' + SysErrorMessage(GetLastError()));<br> &nbsp;end;<br><br> &nbsp;dwAllocSize := sizeof(TBBUTTONINFO);<br><br> &nbsp;pStart &nbsp; &nbsp;:= &nbsp; VirtualAllocEx(hTargetHandle,nil,dwAllocSize,MEM_COMMIT,PAGE_READWRITE);<br> &nbsp;pBufStart := &nbsp; VirtualAllocEx(hTargetHandle,nil,TextBufSize,MEM_COMMIT,PAGE_READWRITE);<br><br> &nbsp;if (pStart = nil) and (pBufStart = nil) then<br> &nbsp;begin<br> &nbsp; &nbsp;Memo1.Lines.Add('Error &nbsp; Open &nbsp; Process. &nbsp; Err=' + SysErrorMessage(GetLastError()));<br> &nbsp;end;<br><br> &nbsp;ButtonCount := SendMessage(hTrayWnd,TB_BUTTONCOUNT,0,0);<br><br> &nbsp;Memo1.Lines.Add('Count &nbsp; = &nbsp; ' + IntToStr(ButtonCount));<br><br><br> &nbsp;for v_Count := 0 to ButtonCount - 1 do<br> &nbsp;begin<br> &nbsp; &nbsp;v_Info.cbSize &nbsp; := &nbsp; dwAllocSize;<br> &nbsp; &nbsp;v_Info.dwMask &nbsp; := &nbsp; TBIF_TEXT;<br> &nbsp; &nbsp;v_Info.pszText &nbsp; := &nbsp; LPTSTR(pBufStart);<br> &nbsp; &nbsp;WriteProcessMemory(hTargetHandle,pStart,Pointer(@v_Info),dwAllocSize, dwWrite);<br><br> &nbsp; &nbsp;New(TempBuf);<br> &nbsp; &nbsp;TempBuf := AllocMem(TextBufSize);<br> &nbsp; &nbsp;ZeroMemory(TempBuf,TextBufSize);<br> &nbsp; &nbsp;WriteProcessMemory(hTargetHandle,pBufStart,Pointer(TempBuf),TextBufSize,dwWrite);<br><br> &nbsp; &nbsp;SendMessage(hTrayWnd,TB_GETBUTTONINFO,v_Count, iNTEGER(PTBBUTTONINFO(pStart)));// &nbsp; Button);<br><br> &nbsp; &nbsp;ReadProcessMemory(hTargetHandle,Pointer(pBufStart),Pointer(TempBuf),TextBufSize,dwRead);<br><br> &nbsp; &nbsp;Memo1.Lines.Add(STRING(TempBuf));<br><br> &nbsp; &nbsp;Dispose(TempBuf);<br> &nbsp;end;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> &nbsp;f_ShowTrayIcon;<br>end;<br><br>end.
 
上面的仁兄讲得很清楚
 
强人,是的,仁兄讲的很清楚了,支持,大家也都可以学学
 
各位老大,这些代码得到的都是图标的弹出信息,怎么才能得到图标本身乃?<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;谢谢!
 
后退
顶部