Home All Groups Group Topic Archive Search About

Embedded controller UI in Windows Service

Author
1 Mar 2006 2:31 AM
Tim Johnson
I built a Windows Service exe, and a separate exe to control it which has a
nice little icon on the system tray.  I'm wondering if there is a "right" way
to merge the two apps such that:

a) when you installutil the service it automatically puts the notifyicon on
the systemtray
b) it will respond to right-click of the icon (even if stopped?)

Or if they have to stay 2 separate apps, if there's a prescribed way to make
the controller app always around (didn't want to have to Schedule it etc,
just wanted it to start up along with the service).

Author
1 Mar 2006 8:05 AM
Simon Murrell
Hello Tim

Keep them separate. If you combine the two into one exe, you will not be
able to start the service again. You could get your users to use the Services
applet to start the service and then use the system tray portion to stop it.
Rather separate them as that is what SQL Server has done with the service
exe and then the Service Manager exe which sits in the system tray.
Hope this helps...

Regards,
Simon

Show quote
"Tim Johnson" wrote:

> I built a Windows Service exe, and a separate exe to control it which has a
> nice little icon on the system tray.  I'm wondering if there is a "right" way
> to merge the two apps such that:
>
> a) when you installutil the service it automatically puts the notifyicon on
> the systemtray
> b) it will respond to right-click of the icon (even if stopped?)
>
> Or if they have to stay 2 separate apps, if there's a prescribed way to make
> the controller app always around (didn't want to have to Schedule it etc,
> just wanted it to start up along with the service).
Author
1 Mar 2006 9:17 AM
Tim Johnson
Makes sense.  I was just trying to figure how to make that icon always be in
the system tray, ie have my svc controller app always running.  I can always
make it a Startup app but I guess I was thinking there might be a prescribed
way to couple the 2 apps - what makes all those other tray icons show up
automatically, aren't most of them related to services or are they just
drivers (wifi, sql server, etc)?

Show quote
"Simon Murrell" wrote:

> Hello Tim
>
> Keep them separate. If you combine the two into one exe, you will not be
> able to start the service again. You could get your users to use the Services
> applet to start the service and then use the system tray portion to stop it.
> Rather separate them as that is what SQL Server has done with the service
> exe and then the Service Manager exe which sits in the system tray.
> Hope this helps...
>
> Regards,
> Simon
>
> "Tim Johnson" wrote:
>
> > I built a Windows Service exe, and a separate exe to control it which has a
> > nice little icon on the system tray.  I'm wondering if there is a "right" way
> > to merge the two apps such that:
> >
> > a) when you installutil the service it automatically puts the notifyicon on
> > the systemtray
> > b) it will respond to right-click of the icon (even if stopped?)
> >
> > Or if they have to stay 2 separate apps, if there's a prescribed way to make
> > the controller app always around (didn't want to have to Schedule it etc,
> > just wanted it to start up along with the service).
Author
1 Mar 2006 11:31 AM
Simon Murrell
Hello Tim

Well the SQL Service Manager is normally added to the Startup menu
in Windows. That is probably the easiest and cleanest way to do it.

Regards,
Simon

Show quote
"Tim Johnson" wrote:

> Makes sense.  I was just trying to figure how to make that icon always be in
> the system tray, ie have my svc controller app always running.  I can always
> make it a Startup app but I guess I was thinking there might be a prescribed
> way to couple the 2 apps - what makes all those other tray icons show up
> automatically, aren't most of them related to services or are they just
> drivers (wifi, sql server, etc)?
>
> "Simon Murrell" wrote:
>
> > Hello Tim
> >
> > Keep them separate. If you combine the two into one exe, you will not be
> > able to start the service again. You could get your users to use the Services
> > applet to start the service and then use the system tray portion to stop it.
> > Rather separate them as that is what SQL Server has done with the service
> > exe and then the Service Manager exe which sits in the system tray.
> > Hope this helps...
> >
> > Regards,
> > Simon
> >
> > "Tim Johnson" wrote:
> >
> > > I built a Windows Service exe, and a separate exe to control it which has a
> > > nice little icon on the system tray.  I'm wondering if there is a "right" way
> > > to merge the two apps such that:
> > >
> > > a) when you installutil the service it automatically puts the notifyicon on
> > > the systemtray
> > > b) it will respond to right-click of the icon (even if stopped?)
> > >
> > > Or if they have to stay 2 separate apps, if there's a prescribed way to make
> > > the controller app always around (didn't want to have to Schedule it etc,
> > > just wanted it to start up along with the service).
Author
1 Mar 2006 11:41 AM
Adam Klobukowski
Simon Murrell napisa³(a):
> Hello Tim
>
> Well the SQL Service Manager is normally added to the Startup menu
> in Windows. That is probably the easiest and cleanest way to do it.

I've written a service and service controller that way (2 separate
apps). I have a problem with controler application: it has a windo that
is always opened, only just hidden or shown to the user. It hase close
widget, but it just hides window (no close). The problem is that when
I'm switching machine off, i prevents it. There is no erro message, or
anything, machine just does not switch off. When I exit it manually -
computer can be switched off.

I tried hooking at Application.ApplicationExit do detect application
going down, but it didn't help. How can I distinguish if Form.Closing
event is fired becouse user clicked close widget or becouse system is
going down?

--
Semper Fidelis

Adam Klobukowski
at***@gabo.pl

AddThis Social Bookmark Button