1

How do I find which Windows process is displaying a given taskbar system tray icon?

Alex
  • 1,249
  • 1
  • 14
  • 14

3 Answers3

2

I've just realised that in Windows 7 the 'Select which icons and notifications appear on the taskbar' menu helps a bit here. Find it by right-clicking the taskbar, go to 'Properties', then click the 'Customize...' button in the 'Notification area' frame.

Each row in that window represents a taskbar icon that Windows Explorer has seen. Of the left two rwos, I believe the top one is the process's description as shown in Task Manager, and the bottom one is the window title for the window showing the taskbar icon.

This would've helped me track down my original problem! VisualSVN was popping up a 'Register me!' nag window in the system tray, despite no obvious VisualSVN processes running. Eventually I noticed that this nag window disappeared when I closed Visual Studio, so it was clear that the VisualSVN add-in DLL loaded in Visual Studio was creating the nag window.

Alex
  • 1,249
  • 1
  • 14
  • 14
1

I don't believe this to be possible. Certainly Spy++ reports that the Notification area is a single window named "User Promoted Notification Area". This window is ultimately parented with the desktop window and has no obvious association with the process that created the notification icon.


Well, by possible I mean possible without resorting to hacks like Anders suggests which is no doubt feasible, but not what I imagine the OP is looking for!

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Well, the question is tagged with debugging. Back in the day there was a product named TraySaver that did this, a couple of MS KB articles even linked to it =) – Anders Mar 02 '11 at 13:13
  • @Anders I take the debugging tag to mean that OP is trying to work out which process of the many that are running is the one that was responsible for the icon. If it was me I'd look at the description and company name in Process Explorer and see if I could find a match. Then I'd kill the process and see if the icon went away! – David Heffernan Mar 02 '11 at 14:49
1

Shell_NotifyIcon works by sending a special WM_COPYDATA message to the taskbar, if you inject into explorer and subclass the taskbar you could catch this message, you could then get the process id by calling GetWindowThreadProcessId on COPYDATAstruct.NOTIFYICONDATA.hwnd.

...and of course, this is a hack and relies on undocumented information that could change at any time!

Anders
  • 97,548
  • 12
  • 110
  • 164
  • If you are going to rely on undocumented implementation details, why bother hooking at all? You can read the internal structures directly via TB_GETBUTTON and ReadProcessMemory (http://www.ureader.com/msg/14841415.aspx) – Luke Mar 02 '11 at 13:35
  • The Toolbar class supports hidden buttons, but I guess that would depend on how Explorer implements hidden icons (is it a hidden button or is there no button at all?). Only one way to find out. – Luke Mar 02 '11 at 18:29
  • Thanks for these 'hacky' solutions, Anders and Luke. It's a shame that there is no documented way to do this. If I need such a hack another time, at least I'll know what's possible. – Alex Mar 05 '11 at 06:02