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

How do I manually create an icon in the system tray?

P: n/a
The conventional approach is easy enough; drop a NotifyIcon onto a Form.
When the form is loaded - bingo - the icon appears in the System Tray.

I can't use this approach though. I'm writing a service. But I'd like my
service to install an icon on the System Tray so that the user can start /
stop / and otherwise control the service interactively, and without having
to go to the Services applet. How do I do this?

Thanks for your advice.

- Joseph Geretz -
Jul 5 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Wed, 04 Jul 2007 22:51:01 -0700, Joseph Geretz <jg*****@nospam.com>
wrote:
The conventional approach is easy enough; drop a NotifyIcon onto a Form.
When the form is loaded - bingo - the icon appears in the System Tray.

I can't use this approach though. I'm writing a service. But I'd like my
service to install an icon on the System Tray so that the user can start
/
stop / and otherwise control the service interactively, and without
having
to go to the Services applet. How do I do this?
Hmmm...I thought that services by definition were not allowed to have UI.
That would preclude the service itself from using the system tray for a
notify icon.

I do note that the "drop a NotifyIcon onto a Form" is just a shortcut for
instantiating a NotifyIcon instance. I suppose you could try doing that
from your service. But because of the above, I wouldn't expect it to work.

If it doesn't work, as predicted, I would expect that the only solution
would be to do what you'd have to do anyway, which is to write an
independent application that communicates with the service, and which
presents the UI to the user. Including (or even limited to) a NotifyIcon,
if that's what you want.

Pete
Jul 5 '07 #2

P: n/a
Adding to what Peter wrote:
<< ...write an independent application that communicates with the
service...>>

If that's what you ultimately must do, then that other application would
interact with your service via the ServiceController class.

For more:
http://msdn2.microsoft.com/en-us/lib...ontroller.aspx

- HTH
Jul 5 '07 #3

P: n/a
Joseph,

Quite simply, you don't do this from your service. This would require
your service to have an interactive user session, which you are not
guaranteed to have.

Rather, you create a program which will be executed when a user logs in
(e.g. put a shortcut to it in the Startup directory) that will place the
icon in the tray (using NotifyIcon).

Your program would then have to use Remoting/WCF (or some other
intra-process mechanism) to communicate with the service.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Joseph Geretz" <jg*****@nospam.comwrote in message
news:OG**************@TK2MSFTNGP02.phx.gbl...
The conventional approach is easy enough; drop a NotifyIcon onto a Form.
When the form is loaded - bingo - the icon appears in the System Tray.

I can't use this approach though. I'm writing a service. But I'd like my
service to install an icon on the System Tray so that the user can start /
stop / and otherwise control the service interactively, and without having
to go to the Services applet. How do I do this?

Thanks for your advice.

- Joseph Geretz -

Jul 5 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.