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_DELETE
works 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:
> bp shell32!Shell_NotifyIconW
> g
(keep using g
until you are inside Shell_NotifyIconW
)
> dd poi(esp+8)+8 L2 ; .echo _________ ^ID ^Flags
I ended up with
0018fba8 00000001 0000000f
_________ ^ID ^Flags
Where 1 is the ID and Flags does not include 0x20 (GUID).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…