By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,277 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,277 IT Pros & Developers. It's quick & easy.

How to add Systray icon when writing windows service using c#

P: n/a
I can add a systray icon in normal windows application...
but when i do it in windows service, the systray icon just don't show up

is that because i don't have any "component" to contain the systray icon?
please give direction...

thx

Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
A service, by default anyway, does not have access to your window station,
so it also doesn't have access to your system tray. You might be able to
work aroudn this with some creative p\invoke, but it wouldn't be highly
recommended.
To do what you want to do you will need to write a seperate application that
displays the system tray icon and communicates whatever is needed with the
service.
"Action" <ac***************@hotmail.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
I can add a systray icon in normal windows application...
but when i do it in windows service, the systray icon just don't show up

is that because i don't have any "component" to contain the systray icon?
please give direction...

thx

Nov 15 '05 #2

P: n/a
You can configure the Service in Services - MMC to allow Desktop
interaction. Afterwards you can display forms, trayicons, ...

GP

"Action" <ac***************@hotmail.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
I can add a systray icon in normal windows application...
but when i do it in windows service, the systray icon just don't show up

is that because i don't have any "component" to contain the systray icon?
please give direction...

thx

Nov 15 '05 #3

P: n/a
Services MMC?
I can't find any option to allow me to do so...

and...if it can be done....can I enable it in the program rather than
manually?
coz it may not be desirable for use to enable it manually when using the
service...

Thank you
"GŁnter Prossliner" <g.**********@gmx.at> wrote in message
news:Oj*************@tk2msftngp13.phx.gbl...
You can configure the Service in Services - MMC to allow Desktop
interaction. Afterwards you can display forms, trayicons, ...

GP

"Action" <ac***************@hotmail.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
I can add a systray icon in normal windows application...
but when i do it in windows service, the systray icon just don't show up

is that because i don't have any "component" to contain the systray icon? please give direction...

thx


Nov 15 '05 #4

P: n/a
I saw some service able to create a systray icon
or it user other shortcuts to do so..?

thx

"Daniel O'Connell" <on******@comcast.net> wrote in message
news:hAV7b.414938$Ho3.65699@sccrnsc03...
A service, by default anyway, does not have access to your window station,
so it also doesn't have access to your system tray. You might be able to
work aroudn this with some creative p\invoke, but it wouldn't be highly
recommended.
To do what you want to do you will need to write a seperate application that displays the system tray icon and communicates whatever is needed with the
service.
"Action" <ac***************@hotmail.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
I can add a systray icon in normal windows application...
but when i do it in windows service, the systray icon just don't show up

is that because i don't have any "component" to contain the systray icon? please give direction...

thx


Nov 15 '05 #5

P: n/a
While it CAN be done, it is not advisable. There is a possiblity of
priviledge elevation via windows message attacks (I don't know if .NET helps
with that or not, but is it worth the risk?).
If you must provide the UI from the service, use the most restrictive
possible user account for the service(Definatly not SYSTEM, LocalSystem,
Administrative accounts, etc, I'd say) lest someone trys to compromise it.
Also, I doubt it is as easy as running a simple winforms application
properly across TS. Client\server really makes more sense and is more
secure, plus it is probably easier to run the client code across multiple
accounts and should allow for remote administration as well(this may not be
a prime issue now, but you may need it at some point).

these urls may be of use as well:
http://support.microsoft.com/default...b;en-us;171890
http://support.microsoft.com/default...b;en-us;308403
http://support.microsoft.com/default...b;en-us;821794
http://support.microsoft.com/default...b;en-us;327618

"Action" <ac***************@hotmail.com> wrote in message
news:ew**************@TK2MSFTNGP09.phx.gbl...
I saw some service able to create a systray icon
or it user other shortcuts to do so..?

thx

"Daniel O'Connell" <on******@comcast.net> wrote in message
news:hAV7b.414938$Ho3.65699@sccrnsc03...
A service, by default anyway, does not have access to your window station,
so it also doesn't have access to your system tray. You might be able to
work aroudn this with some creative p\invoke, but it wouldn't be highly
recommended.
To do what you want to do you will need to write a seperate application

that
displays the system tray icon and communicates whatever is needed with the service.
"Action" <ac***************@hotmail.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
I can add a systray icon in normal windows application...
but when i do it in windows service, the systray icon just don't show up
is that because i don't have any "component" to contain the systray

icon? please give direction...

thx



Nov 15 '05 #6

P: n/a
> Services MMC?
I can't find any option to allow me to do so...
Open Start -> Control Panel -> Administrative Tools -> Services
Open the properties of your Service -> "Log On" --> check "Allow Service
Interaction with Desktop"

and...if it can be done....can I enable it in the program rather than
manually?
coz it may not be desirable for use to enable it manually when using the
service...


This setting is stored in the Registry under:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\YOUR_SERVICE_NAME
Create (or modify) a DWORD Registry Entry named "Type", and write the value
0x110 (decimal: 272) into it. Of caurse you must have the required
permission to do that. If you own them, you can do this during the
installation, or via code.

If you don't want to do this, there will be no other possibility to do this
that create another application that displays the trayicon and communicates
with your services.

mfg GP
Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.