下面的代码可以隐藏掉QQ的图标,你可以结束进程前操作。<br>procedure TForm1.Button3Click(Sender: TObject);<br>var<br> v_hShellTray: THandle;<br> v_hTrayNotify: THandle;<br> v_hToolBar: THandle;<br> i,j:integer;<br> Info: _TBBUTTON;<br> buffer
char;<br> PID: THandle;<br> PRC: THandle;<br> R: Cardinal;<br> S:array[0..1024] of char;<br> MaxWidth: integer;<br> temps:string;<br> lpData
NotifyIconData;<br>begin<br> v_hShellTray := FindWindow('Shell_TrayWnd', nil);<br> v_hTrayNotify := FindWindowEx(v_hShellTray, 0, 'TrayNotifyWnd', nil);<br> v_hToolBar := FindWindowEx(v_hTrayNotify, 0, 'ToolbarWindow32', nil);<br><br> GetWindowThreadProcessId(v_hToolBar, @PID);<br> PRC := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or PROCESS_VM_WRITE, False, PID);<br> Buffer := VirtualAllocEx(PRC, nil, 4096, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE);<br><br> j:=SendMessage(v_hToolBar,TB_BUTTONCOUNT,0,0);<br> for i:=0 to j-1 do<br> begin<br> FillChar(Info, SizeOf(Info), 0);<br> WriteProcessMemory(PRC, Buffer, @Info, SizeOf(Info), R);<br><br> SendMessage(v_hToolBar, TB_GETBUTTON, i, integer(Buffer));<br> ReadProcessMemory(PRC, Buffer, @Info, SizeOf(Info), R);<br> if Info.iString<>-1 then<br> begin<br> SendMessage(v_hToolBar, TB_GETBUTTONTEXT, Info.idCommand, integer(integer(@Buffer[0]) + SizeOf(Info)));<br> ReadProcessMemory(PRC, Pointer(integer(@Buffer[0]) + SizeOf(Info)), @S[0], SizeOf(S), R);<br> temps:=s;<br> if pos('QQ',temps)>0 then<br> begin<br> SendMessage(v_hToolBar, TB_HIDEBUTTON, Info.idCommand, integer(true));<br> break;<br> end;<br> end;<br> end;<br> VirtualFreeEx(PRC, Buffer, 0, MEM_RELEASE);<br> CloseHandle(PRC);<br> //向任务栏添加一个图标后马上删除,使任务栏刷新。<br> lpData := new(PNotifyIconDataA);<br> lpData.cbSize := 88;<br> lpData.Wnd := Form1.Handle;<br> lpData.hIcon := Form1.Icon.Handle;<br> lpData.uCallbackMessage := 0;<br> lpData.uID :=0;<br> lpData.szTip := 'Samples';<br> lpData.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;<br> Shell_NotifyIcon(NIM_ADD,lpData);<br> Shell_NotifyIcon(NIM_DELETE,lpData);<br> dispose(lpData);<br>end;