A way to ensure that a system tray icon is removed... guaranteed

Posted by Brian R. Bondy on Stack Overflow See other posts from Stack Overflow or by Brian R. Bondy
Published on 2009-01-20T03:38:50Z Indexed on 2010/03/12 20:17 UTC
Read the original article Hit count: 180

Filed under:
|
|
|

Is there a way to guarantee that your system tray icon is removed?

To add the system tray icon you do:

Shell_NotifyIcon(NIM_ADD, &m_tnd);

To remove the system tray icon you do:

Shell_NotifyIcon(NIM_DELETE, &m_tnd);

What I want to know: what if you application crashes? The icon stays in your system tray until you mouse over. Is there a way to guarantee that the icon will be removed, even when the application crashes? I would prefer not to use structured exception handling for various reasons.

Another case that I want to handle is when the process is killed, but doesn't necessarily crash.

© Stack Overflow or respective owner

Related posts about winapi

Related posts about system-tray