How to re-add icon to system tray after explorer.exe crash

不问归期 提交于 2019-12-23 17:58:32

问题


My java application currently has an icon in the system tray. When the system tray crashes, however (you can simulate this by killing explorer.exe in the taskbar), the icon disappears after the system tray returns.

When I check SystemTray.getSystemTray().getTrayIcons() for the icons in the system tray, it always shows that my TrayIcon is still in the system tray, even though after it crashes and reloads and my tray icon is longer there.

At the moment I'm removing and adding my icon once every 15 seconds or so, but is there any other way of implementing this so that it won't keep disappearing and appearing and annoying the user?


回答1:


Just a guess.

Check for pid of explorer.exe once in a few seconds. If it has changed, unregister your tray icon and register it again.




回答2:


Just in case anyone else stumbles across this and wonders what happened, in the end I had to stick with removing and adding the icon after a few seconds, because Windows does not update the JVM on the status of the tray icons... It was naturally not the best way to fix it, but there didn't seem to be a better way.



来源:https://stackoverflow.com/questions/7923645/how-to-re-add-icon-to-system-tray-after-explorer-exe-crash

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!