type<br> TOSVersion = (osUnknown, os95, os98, osME, osNT3, osNT4, os2K, osXP, os2K3);<br>......<br>function GetOS: TOSVersion;<br>var<br> OS: TOSVersionInfo; <br>begin<br> ZeroMemory(@OS,SizeOf(OS));<br> OS.dwOSVersionInfoSize := SizeOf(OS);<br> GetVersionEx(OS);<br> Result := osUnknown;<br> if OS.dwPlatformId = VER_PLATFORM_WIN32_NT then<br> begin <br> case OS.dwMajorVersion of<br> 3: Result := osNT3;<br> 4: Result := osNT4; <br> 5: <br> begin <br> case OS.dwMinorVersion of <br> 0: Result:= os2K; <br> 1: Result:= osXP;<br> 2: Result:= os2K3;<br> end; <br> end; <br> end; <br> end <br> else if (OS.dwMajorVersion = 4) and (OS.dwMinorVersion = 0) then <br> Result := os95 <br> else if (OS.dwMajorVersion = 4) and (OS.dwMinorVersion = 10) then <br> Result := os98 <br> else if (OS.dwMajorVersion = 4) and (OS.dwMinorVersion = 90) then <br> Result := osME <br>end;<br><br>function GetSysTrayWnd(): HWND;<br>//返回系统托盘的句柄,适合于Windows各版本<br>var OS: TOSVersion;<br>begin<br> OS := GetOS;<br> Result := FindWindow('Shell_TrayWnd', nil);<br> Result := FindWindowEx(Result, 0, 'TrayNotifyWnd', nil);<br> if(OS in [osXP, os2K3])then<br> Result := FindWindowEx(Result, 0, 'SysPager', nil);<br> if(OS in [os2K, osXP, os2K3])then<br> 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 < rTrayToolBar.right do<br> begin<br> y := 0;<br> while y < rTrayToolBar.bottom do<br> begin<br> SendMessage(hwndTrayToolBar , WM_MOUSEMOVE, 0, MAKELPARAM(x,y) );<br> Inc(y,8);<br> end;<br> Inc(x, 8);<br> end;<br>end;<br><br>===================================<br>调用RefreshTrayIcon()就OK