如何将系统托盘里面失效的图标清除?(刷新系统栏) ( 积分: 200 )

  • 主题发起人 主题发起人 moonight
  • 开始时间 开始时间
M

moonight

Unregistered / Unconfirmed
GUEST, unregistred user!
各位高手帮帮忙!<br>现在我将一个程序通过TerminateProcess方法结束,但它的系统托盘图标还在那里,要用鼠标去晃一下才能消失,好烦的,现在想用Delphi一口气把它全消除,需要刷新一下系统栏,如何做这个操作?<br>恳请各位指点!
 
各位高手帮帮忙!<br>现在我将一个程序通过TerminateProcess方法结束,但它的系统托盘图标还在那里,要用鼠标去晃一下才能消失,好烦的,现在想用Delphi一口气把它全消除,需要刷新一下系统栏,如何做这个操作?<br>恳请各位指点!
 
我已经贴上代码了<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=3174446
 
谢谢帮忙,解决了!<br>分数全给你吧!算是补偿,交个朋友。
 
type<br> &nbsp;TOSVersion = (osUnknown, os95, os98, osME, osNT3, osNT4, os2K, osXP, os2K3);<br>......<br>function GetOS: TOSVersion;<br>var<br> &nbsp;OS: TOSVersionInfo; <br>begin<br> &nbsp;ZeroMemory(@OS,SizeOf(OS));<br> &nbsp;OS.dwOSVersionInfoSize := SizeOf(OS);<br> &nbsp;GetVersionEx(OS);<br> &nbsp;Result := osUnknown;<br> &nbsp;if OS.dwPlatformId = VER_PLATFORM_WIN32_NT then<br> &nbsp;begin <br> &nbsp; &nbsp;case OS.dwMajorVersion of<br> &nbsp; &nbsp; &nbsp;3: Result := osNT3;<br> &nbsp; &nbsp; &nbsp;4: Result := osNT4; <br> &nbsp; &nbsp; &nbsp;5: <br> &nbsp; &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp; &nbsp;case OS.dwMinorVersion of <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0: Result:= os2K; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1: Result:= osXP;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2: Result:= os2K3;<br> &nbsp; &nbsp; &nbsp; &nbsp;end; <br> &nbsp; &nbsp; &nbsp;end; <br> &nbsp; &nbsp;end; <br> &nbsp;end <br> &nbsp;else if (OS.dwMajorVersion = 4) and (OS.dwMinorVersion = 0) then <br> &nbsp; &nbsp;Result := os95 <br> &nbsp;else if (OS.dwMajorVersion = 4) and (OS.dwMinorVersion = 10) then <br> &nbsp; &nbsp;Result := os98 <br> &nbsp;else if (OS.dwMajorVersion = 4) and (OS.dwMinorVersion = 90) then <br> &nbsp; &nbsp;Result := osME <br>end;<br><br>function GetSysTrayWnd(): HWND;<br>//返回系统托盘的句柄,适合于Windows各版本<br>var OS: TOSVersion;<br>begin<br> &nbsp;OS := GetOS;<br> &nbsp;Result := FindWindow('Shell_TrayWnd', nil);<br> &nbsp;Result := FindWindowEx(Result, 0, 'TrayNotifyWnd', nil);<br> &nbsp;if(OS in [osXP, os2K3])then<br> &nbsp; &nbsp;Result := FindWindowEx(Result, 0, 'SysPager', nil);<br> &nbsp;if(OS in [os2K, osXP, os2K3])then<br> &nbsp; &nbsp;Result := FindWindowEx(Result, 0, 'ToolbarWindow32', nil);<br>end;<br><br>procedure RefreshTrayIcon();<br>//刷新系统托盘图标<br>var<br> hwndTrayToolBar : HWND;<br> rTrayToolBar : tRect;<br> x , y : Word;<br>begin<br> hwndTrayToolBar := GetSysTrayWnd;<br><br> Windows.GetClientRect(hwndTrayToolBar, rTrayToolBar);<br> x := 0;<br> while x &lt; rTrayToolBar.right do<br> begin<br> &nbsp; y := 0;<br> &nbsp; while y &lt; rTrayToolBar.bottom do<br> &nbsp; begin<br> &nbsp; &nbsp; SendMessage(hwndTrayToolBar , WM_MOUSEMOVE, 0, MAKELPARAM(x,y) );<br> &nbsp; &nbsp; Inc(y,8);<br> &nbsp; end;<br> &nbsp; Inc(x, 8);<br> end;<br>end;<br><br>===================================<br>调用RefreshTrayIcon()就OK
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
451
import
I
后退
顶部