tags:

views:

403

answers:

2

How can I display a system tray icon for C# window service.?

+6  A: 

You can't, not directly, because the windows service will necessarily start when the machine does, not when a user logs in. The service will also be running in a different context, likely as a different user.

What you can do is to write a separate system tray based "controller" that interacts with the service.

Bevan
+11  A: 

Services run in a different window station than the logged in user, so you can't have a system tray icon for them.

http://msdn.microsoft.com/en-us/library/d56de412.aspx

Here are a couple of links about how to write to the system tray. You'll need another application to interface with the service, since the service can't directly have an icon in the system tray.

http://stackoverflow.com/questions/995195/writing-a-windows-system-tray-application-with-net

and

http://msdotnetsupport.blogspot.com/2008/02/cnet-application-windows-system-tray.html

Kevin