一种确保系统托盘图标被删除的方法...保证 [英] A way to ensure that a system tray icon is removed... guaranteed

查看:245
本文介绍了一种确保系统托盘图标被删除的方法...保证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法确保系统托盘图标已删除?

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.

推荐答案

大多数程序员忘记检查的另一件事是,如果资源管理器重新启动/崩溃。

Another thing most programmers forget to check for is if the explorer restarts/crashes. Its nice if the application handle this and recreate its own icon.

只需检查消息WM_TASKBARCREATED并重新创建该图标。

Just check for Message WM_TASKBARCREATED and recreate the icon.

这篇关于一种确保系统托盘图标被删除的方法...保证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆