NotifyIcon not showing

前端 未结 2 1392
后悔当初
后悔当初 2021-01-03 15:05

I am writing a simple application that I would like to control with a notifyIcon rather than a form, I have follwed examples I found through Google, but my notifyIcon will n

2条回答
  •  有刺的猬
    2021-01-03 15:13

    One more reason why NotifyIcon is not shown is if Windows Explorer is running with elevated privileges while your tray application isn't (only on systems with UAC of course).

    This can happen if explorer.exe crashed or was killed, and then user manually restarted it from the elevated Task Manager.

    NotifyIcon control uses Shell_NotifyIcon native method inside, but doesn't check for the return value. If Shell_NotifyIcon returns FALSE, you won't be ever notified.

    I had to breakpoint with WinDbg on Shell_NotifyIcon and GetLastError gave me ERROR_ACCESS_DENIED. So I realized that there's a permission issue, and it might be caused by restarted explorer elevation. Further tests confirmed this assumption.

    However this is rather rare case.

提交回复
热议问题