发新话题
打印

如何自动移去系统托盘失效的图标

如何自动移去系统托盘失效的图标

  有些Window应用程序在启动以后会在系统托盘去添加一个小图标, 一般情况下当程序正常退出时会自动去掉,但有时由于应用程序非法关闭,这个图标便一直留在托盘区,直到用鼠标移动图标上时,才会自己消失.那么我们就可以模拟鼠标移动到逐个图标上,来达到这个效果.

void __fastcall RemoveDeadIcons()
{
    HWND hTrayWindow;
    RECT rctTrayIcon;
    int nIconWidth;
    int nIconHeight;
    TPoint CursorPos;
    int nRow;
    int nCol;

    // Get tray window handle and bounding rectangle
    hTrayWindow = FindWindowEx(FindWindow(
            "Shell_TrayWnd", NULL), 0, "TrayNotifyWnd", NULL);
    if(!GetWindowRect(hTrayWindow,

TOP

发新话题