杀掉explorer进程后,windows taskbar也就没有了,托盘图标也就跟着消失了。当explorer进程重启,taskbar将会被创建,taskbar创建后会使用字符串“TaskbarCreated”注册一个消息,然后将这个消息广播到它的所有top-level windows。因此我们可以去注册并捕获这个消息,然后在消息处理函数中调用
Shell_NotifyIcon(NIM_ADD, &m_nid); 重新将托盘图标添加上
MSDN中的说明:
Taskbar Creation Notification
Microsoft® Internet Explorer 4.0 will notify applications that the taskbar has been created. When the taskbar is created, it will register a message with the "TaskbarCreated" string and then broadcast this message to all top-level windows. When your taskbar application receives this message, it should assume that any taskbar icons it added have been removed and add