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



Hi Peter,

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.

Is this really true? I have about a dozen icons in my Tray, about half of
them represent running services (e.g. PCAnywhere, SQL Server, Bluetooth,
etc.).

Writing a service is a bit of a black art from what I can see; Since a
service won't run in the IDE it's difficult to step through the code during
the development in order to test it. What I've done is implemented an #if
DEBUG conditional compiler statement in the Program module to define two
separate Main methods. If running in Debug, the program installs an icon in
the System Tray which allows the developer to test Start / Stop, etc. In
short, all of the conditions which would be encountered when running as a
legitimate Service at production runtime. Having done this, it would be nice
if I could leverage this interactive control infrastructure for runtime, but
if not, not.

Are there any whitepapers which describe logistics and best-practices for
service development using Visual Studio 2005? I am managing, but if there
are specific recommendations and approaches which work better than others,
I'd like to read up on them.

Thanks for your advice.

- Joseph Geretz -

"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message
news:op.tuzbdcib8jd0ej@xxxxxxxxxxxxxxxxxxxxxxx
On Wed, 04 Jul 2007 22:51:01 -0700, Joseph Geretz <jgeretz@xxxxxxxxxx>
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


.



Relevant Pages

  • Re: How do I manually create an icon in the system tray?
    ... When the form is loaded - bingo - the icon appears in the System Tray. ... I do note that the "drop a NotifyIcon onto a Form" is just a shortcut for instantiating a NotifyIcon instance. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Running an windows app in memory
    ... a nifty example of using a NotifyIcon in the ... Must also occur before encountering any code that creates a WinForms object, ... I find the setting of the ShowBalloonTip of the icon parameter makes no ... or having the icon persist in the system tray after you ...
    (microsoft.public.dotnet.languages.csharp)
  • Newbie question - Service and NotifyIcon
    ... puts a NotifyIcon in the system tray. ... OK but I don't get the icon in the system tray when I log in. ... for newly-logged-in desktops to add the NotifyIcon to? ...
    (microsoft.public.dotnet.languages.vb)
  • NotifyIcon "sticks" to system tray after closing
    ... NotifyIcon, the icon stays visible in the system tray. ... It only disappears ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Outlook 2003 System Tray Icon
    ... You can however hide the outlook icon in the system tray by ... it appears that I cannot be rid of the Outlook 2003 icon in the ... || He expects a program to run without appearing on either the Taskbar ...
    (microsoft.public.outlook)