Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get my Windows Service to display in the system tray?

I have a Windows Service that runs in the background when the PC starts. I want to display an Icon on the system tray to allow configuration after a user has logged in but can't find how to do this.

Is there an event I should be looking for which tells me that a user has logged in?

As I understand Windows Services can't have a UI so do I need to start an app to display the sys tray icon? How can I pass configuration updates to my service.

like image 753
Swinders Avatar asked Mar 17 '09 14:03

Swinders


1 Answers

You will want a seperate "agent" application for this. A Windows service is global, running at the system level. There can be multiple desktops running on the system at once, so while there are ways of allowing services to interact with the desktop layer, it is far from trivial to interact with the "users desktop" in the same manner that you do with an application already bound to a specific login/desktop environment.

There are also security risks involved with having a service tunnel into the desktop environment (it opens up a pathway to a system account unless the service runs on a more restricted one), which is why interacting with the desktop is disabled by default.

like image 50
David Avatar answered Nov 11 '22 01:11

David