Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating and installing a service?

3 views
Skip to first unread message

jodleren

unread,
Nov 2, 2009, 10:48:47 AM11/2/09
to
Hi all

I am trying to create a service, but I have some problems. Seaching
the net is not easy, as the words are so common :)
Therefore:

1) I have a project file and my Class(TService). Do I need more?
2) I asume that a settings window is just a form, which I can make
popup, but how?
I do not want to have it in the tray, as that could result in too many
icons there?
3) how do I install it from Delphi?
4) how do I install on the clients computer?

WBR
Sonnich

Maarten Wiltink

unread,
Nov 2, 2009, 11:27:36 AM11/2/09
to
"jodleren" <son...@hot.ee> wrote in message
news:d74c4f78-6332-43e6...@d5g2000yqm.googlegroups.com...

> I am trying to create a service, but I have some problems. Seaching
> the net is not easy, as the words are so common :)
> Therefore:
>
> 1) I have a project file and my Class(TService). Do I need more?

You probably need to instantiate it somewhere. Doesn't the help file
say? I think my service used a datamodule with some component on it,
but I don't remember exactly. I can look it up later.


> 2) I asume that a settings window is just a form, which I can make
> popup, but how?

You don't.

A service should be considered disconnected from anything desktop-
related, since it will be running when nobody is logged on, or when
a dozen users are. Write a separate program that communicates with
the service through named pipes or TCP sockets or something. Yes,
your service probably needs to grow a new interface for that.


> I do not want to have it in the tray, as that could result in too
> many icons there?

"...disconnected from anything desktop-related..."

You can have a normal program that 'minimises to the tray', but it
will be a separate program. It can be the same program as the
configurator client above.


> 3) how do I install it from Delphi?

I think I used the instsrv program from the NT Resource Kit.

Something that bit me: the service executable must be present on a
local drive or the service won't run. I tried to run it from my
home directory on a mapped network drive at first. That doesn't work.


> 4) how do I install on the clients computer?

I imagine a good installer-generator will support that.

Groetjes,
Maarten Wiltink


Philip

unread,
Nov 2, 2009, 1:05:07 PM11/2/09
to
Tune in to alt.comp.lang.borland-delphi again next week
when you'll hear jodleren say:

Never tried it myself, but:

http://www.tolderlund.eu/delphi/service/service.htm

--
Bye,
Philip

Rob Kennedy

unread,
Nov 5, 2009, 4:05:27 AM11/5/09
to
jodleren wrote:
> 3) how do I install it from Delphi?

You don't. Your service installs itself. You could add the "/install"
switch to the program's parameters in the run-configuration dialog. (I
don't remember the name of the menu item, but it's on the Project menu.)

> 4) how do I install on the clients computer?

Have your installer program run the service with the "/install"
command-line switch.

Check out the code for TServiceApplication.Run,
TServiceApplication.RegisterServices, and your service's OnBeforeInstall
and OnAfterInstall events.

--
Rob

jodleren

unread,
Nov 6, 2009, 11:22:33 AM11/6/09
to

Thanks to all for the help. It works, thoug a few questiosn for the
specialist:

1) I have an option, so the service can stop itself. But, Terminate
does not work in a service as in a thread.
As of now I have my own check for that, but is that a proper solution?
while not terminated and bMyRun do....

2) Also, how can I set my service to run (start) automatically?

I admit, I havent read it all, as this should be done i a hurry.
Basically I am already late :)

WBR & thanks
Sonnich

Maarten Wiltink

unread,
Nov 7, 2009, 8:37:10 AM11/7/09
to
"jodleren" <son...@hot.ee> wrote in message
news:ff644140-1013-4420...@b2g2000yqi.googlegroups.com...
[...]

> 1) I have an option, so the service can stop itself. But, Terminate
> does not work in a service as in a thread.
> As of now I have my own check for that, but is that a proper solution?
> while not terminated and bMyRun do....

My service doesn't even have such a main loop. It listens on one or
two ports through components that are on a datamodule. When the
service controller wants to close it, it does - but I have no idea
what exactly happens.


2) Also, how can I set my service to run (start) automatically?

My Computer, Manage, Services and Applications, Services,
<Your service>, Properties, Startup Type, Automatic. (Windows 2000.)

Or you set the StartType of your TService descendent to stAuto in
the Object Inspector and it will probably use that when installing
itself.


> I admit, I havent read it all, as this should be done i a hurry.
> Basically I am already late :)

False economy. Now you're wasting our time _and_ yours. Read up on
all methods, properties, and events of TService. Should take less
than two hours, will probably save you those two hours within a day.

Groetjes,
Maarten Wiltink


0 new messages