I am trying to catch the uID variable from the NOTIFYICONDATA struct, used in Shell_NotifyIcon function (shellapi.h). I got the hWnd of the process window and hIcon the handle of the icon.
The application does not provide a way to hide the system tray icon.
I am looking forward to delete the icon by executing a code using Shell_NotifyIconA function NIM_DELETE to hide the specific icon of a specific proccess I don't have the access to it's source code.
What I was trying to do:
- I got the hWnd by using user32.dll findWindow function
- I got the hIcon by sending a request to hWnd for receving back the hIcon value
Windows allows the user to hide icons they don't care about, there is no reason to resort to hacks on WinXP and later. For older versions, you can take a look at TraySaver.
Officially the tray items are identified by hWnd + ID or GUID but it is possible that Windows cares about the process id and/or exe name as well. If this is the case, you would have to inject into the process.
You can use a debugger on said application and just set a breakpoint on shell32!Shell_NotifyIconW to figure out the ID used by the application you are interested in. The hIcon is not part of the identity.
I just tested and
NIM_DELETEworks just fine if you just know the HWND and ID (assuming it does not use a GUID).In WinDbg, open the exe in question and do this to find the ID:
(keep using
guntil you are insideShell_NotifyIconW)I ended up with
Where 1 is the ID and Flags does not include 0x20 (GUID).