[DUG] basic Service question

Dave O'Brien dave at ICCS.CO.NZ
Fri Oct 9 11:09:31 NZDT 2009


Whenever I have tried to create a service I've always started with
similar problems. I seems to me that you need to use the Start, Stop and
Execute methods, and assign Started and Stopped. So maybe move your
thread creation code into the Execute method and loop while waiting for
it to terminate?

 

From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Robert martin
Sent: Friday, 9 October 2009 11:00 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] basic Service question

 

Yeah :)


My code isn't using the onExecute I am actually starting and stopping my
own Tthread on the onStart event.  However The actual (current) problem
I am having is that even with no code whatsoever I cant register my
service (which I need to do at some point and apparently need for
debugging).

Cheers







Dave O'Brien wrote: 

Something like this?
 
var
  Stopped: Boolean = false ;
 
procedure TsvcSomeService.ServiceExecute(Sender: TService);
var
  t: TDateTime ;
begin
  try
    t := now - 720 ;
    While (not terminated) and (not stopped) do
    begin
      if now > t + (1/1440) then // Run once a minute
      begin
        // Do something
        t := now ;
      End ;
      Sleep(1000) ; // Sleep to allow other services time...
    end ;
  except
  end ;
end;
 
procedure TsvcSomeService.ServiceStart(Sender: TService;
  var Started: Boolean);
begin
  Started := True ;
  Stopped := False ;
end;
 
procedure TsvcSomeService.ServiceStop(Sender: TService;
  var Stopped: Boolean);
begin
  Stopped := True ;
end;
 
procedure TsvcSomeService.ServiceCreate(Sender: TObject);
begin
  // Create some stuff
end;
 
procedure TsvcSomeService.ServiceShutdown(Sender: TService);
begin
  Stopped := True ;
end;
 
-----Original Message-----
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Robert martin
Sent: Friday, 9 October 2009 10:34 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] basic Service question
 
Hi
 
I am trying to create a service 9never done this before) and following
some old instructions I found on the web.  The suggest creating a
service then installing it with service.exe /install then adding code
and debuggin.  I am failing at the most basic point.  I am trying to
install on Vista from cmd line.  It just comes up with a 'program is not
responding message.
 
Any help would be appreciated :)
Rob
 
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
unsubscribe
 
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.421 / Virus Database: 270.14.7/2422 - Release Date:
10/08/09 06:39:00
 
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
unsubscribe
 
  

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.421 / Virus Database: 270.14.7/2422 - Release Date:
10/08/09 06:39:00

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20091009/0f692969/attachment.html 


More information about the Delphi mailing list