views:

185

answers:

3

I've always been curious to see if I can show, hide or change a NotifyIcon created by another application via a C# application.

Could someone please post an example on how to do this? :)

A: 

I am not aware of anything, unless that other application exposes some public method, or you try to use reflection, but I'm not even sure that you can do that on a running process.

Mitchel Sellers
+2  A: 

To modify icons in the systray, you can use Shell_NotifyIcon Win32 API (P/Invoke declaration). The icons are associated with a window handle and an id. That means that to modify or hide another program's icon, you need to know the window and the id used by that application to register it. You might be able to brute force it by enumerating all windows for that process and making calls with each handle and each number between 0 and 5000 thousands for example, but your chances of success are very slim.

Franci Penov
Thanks. Every time I have tried this method using NIM_DELETE I have failed miserably, but your brute force idea has invoked thinking...
RodgerB
+1  A: 

You can hook the SystemTray window itself to intercept all Shell_NotifyIcon() requests. Then you will know the exact HWNDs and IDs that are registered for each icon. Details can be found via any search engine.

Remy Lebeau - TeamB