Can I re-gain a systray icon of a running app that has gone missing?

后端 未结 3 892
春和景丽
春和景丽 2021-02-03 15:26

Since I\'ve finally got an answer for this question: Can you send a signal to windows explorer to make it refresh the systray icons, that asks about getting rid of dead systray

3条回答
  •  走了就别回头了
    2021-02-03 15:44

    Restoring the task bar icon is something that is implemented by the application itself (rather than Explorer). There is a window message called "TaskbarCreated" (its value can be obtained with RegisterWindowMessage("TaskbarCreated")) that an application needs to respond to, in order to restore the task bar icon when necessary.

    For example, the application can do this:

    const int uTaskbarCreatedMsg = RegisterWindowMessage("TaskbarCreated");
    

    Then in its WndProc function:

    LRESULT CALLBACK WndProc(HWND w, UINT msg, WPARAM wparam, LPARAM lparam)
    {
        // ... handle other messages
        if (msg == uTaskbarCreatedMsg) {
            NOTIFYICONDATA nid;
            // fill in details to create icon
            Shell_NotifyIcon(NIM_ADD, &nid);
            return 0;
        }
        // ... default message handling
    }
    

    So in order to force an application to restore its task bar icon, you will need to send the same TaskbarCreated message to the appropriate window within the application. One way to get the HWND to the window is to use FindMessage (and since Apache Monitor is open source, it's easy to discover which window to look for).

提交回复
热议问题