Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
172 views
in Technique[技术] by (71.8m points)

c# - Is there a way of finding uID of a specific application?

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
question from:https://stackoverflow.com/questions/65888147/is-there-a-way-of-finding-uid-of-a-specific-application

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...