Is there a way (in C#) to access the systray? I am not talking about making a notify icon. I want to iterate through the items in the tray (I would guess through the processes but I don't know how to determine what is actually in the tray and what is just a process) and also represent the items with their icons in my own ui.
How do you feel about Win32 interop? I found C/Win32 code that might do the trick for you. (Actually, it looks like an interesting problem so I might try to tackle it myself, just not now).
The magic appears to be that he gets a handle to the system tray's window:
NotifyWnd = FindWindowEx(SysTray, 0, "TrayNotifyWnd", 0);
Then he sets a hook on its message pump:
hHook=SetWindowsHookEx(WH_CALLWNDPROC,HOOKPROC(MsgProc),
hInstance,dwExplorerThreadId);
Then during the message pump hook callback, he gets a reference to some pointer data about the window:
TWDataT* twd=(TWDataT*)GetWindowLong(NotifyWnd,0);
The mystery is then his loop:
pTWIconDataT p=COMCTL32_332(twd->iconsInfo,i);
COMCTL32_332 is defined with GetProcAddress and points to ordinal 332 of Comctl32.dll - according to my checking with Dependency Viewer, that's DPA_GetPtr, which gets data from a dynamic pointer array. I'm not familiar with what's going on behind the scenes there, but it doesn't seem entirely out of the question.
I'm going to play with this a bit myself, but hopefully it's a good place to get you started. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With