有一个进程,在程序外部的,已经用KILL杀掉了,但仍然有一个废弃的图标在任务栏中,就是在右边的小托盘中,鼠标移动过去才会消失。因为我需要多次启动同一个进程,也会多次关闭同一个进程,所以小托盘图标会越来越多,怎样才能去掉?用程序去掉,因为没人来操作这台计算机的:(   
    
  谢谢! 

解决方案 »

  1.   

    function GetSysTrayWnd: HWND;
    {
      返回系统托盘的句柄,适合于WinXP以上版本
    }
    begin
      Result := FindWindow('Shell_TrayWnd', nil);
      Result := FindWindowEx(Result, 0, 'TrayNotifyWnd', nil);
      Result := FindWindowEx(Result, 0, 'SysPager', nil);
      Result := FindWindowEx(Result, 0, 'ToolbarWindow32', nil);
    end;刷新系统托盘procedure RefreshTrayIcon;
    {
      刷新系统托盘图标
    }
    var
     hwndTrayToolBar : HWND;
     rTrayToolBar : tRect;
     x , y : Word;
    begin
     hwndTrayToolBar := GetSysTrayWnd; Windows.GetClientRect(hwndTrayToolBar, rTrayToolBar);
     x := 0;
     while x < rTrayToolBar.right do
     begin
       y := 0;
       while y < rTrayToolBar.bottom do
       begin
         SendMessage(hwndTrayToolBar , WM_MOUSEMOVE, 0, MAKELPARAM(x,y) );
         inc(y,8);
       end;
       inc(x, 8);
     end;
    end;