Link to home
Start Free TrialLog in
Avatar of woodsmj
woodsmj

asked on

Removing another program's Icon from systray.

How can you remove another application's icon from the systray programatically? shell_notifyicon is no use without knowing the the .uID param of NOTIFYICONDATA struct. I have used Soft Ice to determine that shell_notifyicona actually just invokes SendMessage(shell_trayhwnd, WM_COPYDATA, hwnd source, COPYDATA struct), where the COPYDATA struct must contain info gleaned from the NOTIFYICONDATA struct originally passed to shell_notifyicon. If I could get a handle to the icon, I would just use DestroyIcon... but I can't seem to find a way to get the handle to the icon.
Avatar of idcanada
idcanada


TerminateProcess API or others should do.
However, you must kill the parent that has set this icon.

The icon in this systray could have been set with a small
form from an application.
You can not remove the form, however, killing the main application, you kill the form.


Avatar of woodsmj

ASKER

I need to clarify. I do not want to kill the application or process: I simply want to remove its icon from the systray. Ie.- I am writing a replacement front end for dial up networking for a cleitn with expanded functionality and put my own icon in the systray. I do not wish to have Mico$oft's default animated connection icon there while my app is running, but rnaapp.exe still needs to be running, as it exposes the RAS APIs.
A solution may be: find the handle of the traywindow(findwindow using TrayWnd class), then look for child windows that match you icon (by name). Then just hide the icon, remove it or do whatever you want
Avatar of woodsmj

ASKER

I have enurmerated all child windows and none of them have anything to do with the systray. In fact, the "icon area" of the systray is of class TrayNotify_Wnd and has no children. There must be an HDC or something I can grab for that icon. I have also tried getting a window handle by using the popup menu, but this window handle points to the main app hwnd.
ASKER CERTIFIED SOLUTION
Avatar of covington
covington

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of woodsmj

ASKER

Actually... need to do this programmatically, but i'll give you the points anyway so the question doesn't hang around forever...

Thanks for the points...and how did you get that menu handle?