Is there a way of finding uID of a specific application?

322 Views Asked by At

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
1

There are 1 best solutions below

3
On

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).