You first create a New -> service application,
then add one or several services to the service application.
I ended up running my service in another thread, as I was using COM stuff
and found this was the only way to initialise and finalise COM. This is
because each service runs on a different thread from the main service
application.
After looking at the source code, it appears that if you have an OnExecute
event handler, that this only gets called once and the service then appears
to Exit. If you do not have one, then it sits in a message loop. So if you
have a timer, start it in the OnStart event, and wait for it to trigger
using your normal timer event handling.
(I could be wrong about this).
If you want to look at the source, the two important routines are
TServiceThread.Execute and TServiceThread.ProcessRequests(WaitForMessage:
Boolean) in unit SvcMgr.
Myles.
> -----Original Message-----
> From: Mark Derricutt [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, 14 April 2000 17:02
> To: Multiple recipients of list delphi
> Subject: [DUG]: NT Services
>
> Hiho all, I'm wanting to create an NT service and am created a new project
> using the Service entry from file->new but not quite sure what it is I'm
> supposed to do next :)
>
> What exactly is a TService object (looks like a datamodule) and how should
> I be writing this properly :)
>
> I understand what I should be doing in OnStop/OnStart/OnShutdown etc., but
> what exactly would I do doing in the OnExecute event? The help for this
> event says "this is where I implement the service", but I'm sort of
> confused as to what exactly I would be doing in this event, when it's
> called, how often its called etc. etc.
>
> My logic says I'd put a TTimer on the TService do my processing in there
> but that again leaves me confused about the OnExecute event. One possible
> thought is that OnExecute gets called when the user double clicks on the
> service name in the control panel services applet, is this so?
>
> Also, how would I set up sending messages and info back and forth to the
> services, i.e. Program A on \\WORKSTATION queries Service B on \\SERVER
> and Service B sends text back to Program A? Is that possible? Easy?
>
> Mark
> The NTService Clueness Newbie :)
>
> --
> Mark Derricutt "People in prayer for me, everyone there for me,
> ICQ: 1934853 sometimes I feel I should face this alone, my
> Wrk: 377-9941 soul exposed... it calm's me to know that I
> Fax: 377-9947 won't!" = Dream Theater - Scarred
> DDI: 375-3754
>
> Now Playing: Control Denied - Consumed
>
> --------------------------------------------------------------------------
> -
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz