Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there a way to programmatically remove a leftover notifyicon from some other program still showing in the tray?
Posted

In older versions of Windows (pre-Windows 7), you could force the tray area to refresh/redraw to do this. But I am not sure it will still work on Windows 7.

Edit/Update
------------

This is in response to your comment. There are two cases where a rogue icon is left behind:

1) When the app exits without explicitly removing the icon. This now invalidates the icon handle. By forcing a refresh of the inner toolbar window, this icon will be auto-removed. You can see this if you move your mouse around the orphan icon.

2) The app crashes and goes into a zombie state without the process actually terminating. In this case there's not much you can do in a documented manner. But if you want to go the undocumented route, take a look at this article I wrote a few years ago:

http://www.codeproject.com/KB/applications/ShellTrayInfo.aspx[^]

It's not been tested on Windows 7 so I have no idea how that'll pan out on that OS.
 
Share this answer
 
v2
Comments
rick at abc 26-Oct-10 16:21pm    
You can refresh the tray but that just repaints the existing. it won't make the leftover icon disapear. The refresh doesn't verify that the app that displayed the icon is "no longer".
Nish Nishant 26-Oct-10 17:01pm    
I've updated my answer in response to your comment.
Thank you for your fast response.
In my case, I'm purposely killing a process that creates what you’re calling a “rogue icon” left in the tray.
I found the following article and grabbed the code I need.
Again, thanks…
http://www.codeproject.com/KB/system/TrayIconBuster.aspx
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900