- //刷新任务栏图标
- function RefreshTaskbarIcon: Integer;
- var
- hShellTrayWnd: HWND; //任务栏窗口
- hTrayNotifyWnd: HWND; //任务栏右边托盘图标+时间区
- hSysPager: HWND; //不同系统可能有可能没有这层
- hToolbarWindow32: HWND; //托盘图标窗口
- r: TRECT;
- width, height: integer;
- x: Integer;
- begin
- hShellTrayWnd := FindWindow(‘Shell_TrayWnd‘,nil);
- hTrayNotifyWnd := FindWindowEx(hShellTrayWnd,0,‘TrayNotifyWnd‘,nil);
- hSysPager := FindWindowEx(hTrayNotifyWnd,0,‘SysPager‘,nil);
- if (hSysPager <> 0) then
- hToolbarWindow32 := FindWindowEx(hSysPager,0,‘ToolbarWindow32‘,nil)
- else
- hToolbarWindow32 := FindWindowEx(hTrayNotifyWnd,0,‘ToolbarWindow32‘,nil);
- if (hToolbarWindow32 <> 0) then
- begin
- GetWindowRect(hToolbarWindow32,r);
- width := r.right - r.left;
- height := r.bottom - r.top;
- //从任务栏中间从左到右 MOUSEMOVE一遍,所有图标状态会被更新
- for x := 1 to width-1 do
- SendMessage(hToolbarWindow32,WM_MOUSEMOVE,0,MAKELPARAM(x,trunc(height/2)));
- end;
- end;
时间: 2024-10-29 19:08:50