<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks for the tips :)<br>
<br>
This is actually an existing app that I am moving to a service so my
debugging was really more getting my head around the service stuff.
You code bel<br>
ow it pretty much what I am doing except that when I register the app
with myService.exe /Install Vista comes up with 'myService.exe has
stopped working ... Windows is checking for a solution to the problem'.<br>
<br>
Ta<br>
Rob
<div class="moz-signature">
<div class="Section1">
<p class="MsoNormal"><span style="" lang="EN-NZ"><o:p> <br>
</o:p></span></p>
</div>
</div>
<br>
<br>
Kyley Harris wrote:
<blockquote
cite="mid:6f7834060910081548m529745e9taa7b3d297a6f8398@mail.gmail.com"
type="cite">With All my services I follow the same thing.. which is
<div><br>
</div>
<div>1:/ Create a Wrapper object which holds the Guts of the service,
Including the fact that my service code is always 1 or more Threads
that instantiate to do work, such as TCP Listening threads etc. The
Wrapper object is really just a pointer to all the threads.</div>
<div><br>
</div>
<div>2. Create a TService object. and a TForm Object.. </div>
<div><br>
</div>
<div>3. in the program file I test a command line switch, and test
for /APP etc.. and for debugging I run the code as an application from
the form with a Start And Stop Button.. (no service code for debugging)</div>
<div><br>
</div>
<div>4.. when installing you just run the app with a command line
param /install or /uninstall you dont need to use the service
application.</div>
<div><br>
</div>
<div>the TService only ever uses Service Start. and Servicestop</div>
<div><br>
</div>
<div>
<div>procedure TFITv2Service.ServiceStart(Sender: TService; var
Started: Boolean);</div>
<div>begin</div>
<div>// SvcLog.Service := self;</div>
<div> Started := True;</div>
<div> try</div>
<div> StartServer;</div>
<div> HssLog('SERVER START IS COMPLETE',hltNormal);</div>
<div> except</div>
<div> on E:exception do</div>
<div> begin</div>
<div> HssLogExcept(e);</div>
<div> Started := false;</div>
<div> end;</div>
<div><br>
</div>
<div><br>
</div>
<div> end;</div>
<div>end;</div>
<div><br>
</div>
<div>procedure TFITv2Service.ServiceStop(Sender: TService; var
Stopped: Boolean);</div>
<div>begin</div>
<div> StopServer;</div>
<div>// SvcLog.Service := nil;</div>
<div><br>
</div>
<div>end;</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div class="gmail_quote">On Fri, Oct 9, 2009 at 11:24 AM, Robert
martin <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:rob@chreos.co.nz">rob@chreos.co.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
Will try that :)<br>
<div>
<div><span style="color: rgb(255, 153, 0);" lang="EN-NZ"></span> <br>
<p class="MsoNormal"><span lang="EN-NZ"> </span></p>
</div>
</div>
<br>
<br>
Dave O'Brien wrote:
<blockquote type="cite">
<div>
<p class="MsoNormal"><span
style="font-size: 11pt; color: rgb(31, 73, 125);">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?</span></p>
<p class="MsoNormal"><span
style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>
<div>
<div
style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0cm 0cm;">
<p class="MsoNormal"><b><span
style="font-size: 10pt; color: windowtext;" lang="EN-US">From:</span></b><span
style="font-size: 10pt; color: windowtext;" lang="EN-US">
<a moz-do-not-send="true"
href="mailto:delphi-bounces@delphi.org.nz" target="_blank">delphi-bounces@delphi.org.nz</a>
[<a moz-do-not-send="true" href="mailto:delphi-bounces@delphi.org.nz"
target="_blank">mailto:delphi-bounces@delphi.org.nz</a>] <b>On
Behalf
Of </b>Robert martin<br>
<b>Sent:</b> Friday, 9 October 2009 11:00 a.m.<br>
<b>To:</b> NZ Borland Developers Group - Delphi List<br>
<b>Subject:</b> Re: [DUG] basic Service question</span></p>
</div>
</div>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Yeah :)<br>
<br>
<br>
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).<br>
<br>
Cheers</p>
<div>
<div>
<p class="MsoNormal"><br>
<br>
</p>
</div>
</div>
<p class="MsoNormal"><br>
<br>
Dave O'Brien wrote: </p>
<pre>Something like this?</pre>
<pre> </pre>
<pre>var</pre>
<pre> Stopped: Boolean = false ;</pre>
<pre> </pre>
<pre>procedure TsvcSomeService.ServiceExecute(Sender: TService);</pre>
<pre>var</pre>
<pre> t: TDateTime ;</pre>
<pre>begin</pre>
<pre> try</pre>
<pre> t := now - 720 ;</pre>
<pre> While (not terminated) and (not stopped) do</pre>
<pre> begin</pre>
<pre> if now > t + (1/1440) then // Run once a minute</pre>
<pre> begin</pre>
<pre> // Do something</pre>
<pre> t := now ;</pre>
<pre> End ;</pre>
<pre> Sleep(1000) ; // Sleep to allow other services time...</pre>
<pre> end ;</pre>
<pre> except</pre>
<pre> end ;</pre>
<pre>end;</pre>
<pre> </pre>
<pre>procedure TsvcSomeService.ServiceStart(Sender: TService;</pre>
<pre> var Started: Boolean);</pre>
<pre>begin</pre>
<pre> Started := True ;</pre>
<pre> Stopped := False ;</pre>
<pre>end;</pre>
<pre> </pre>
<pre>procedure TsvcSomeService.ServiceStop(Sender: TService;</pre>
<pre> var Stopped: Boolean);</pre>
<pre>begin</pre>
<pre> Stopped := True ;</pre>
<pre>end;</pre>
<pre> </pre>
<pre>procedure TsvcSomeService.ServiceCreate(Sender: TObject);</pre>
<pre>begin</pre>
<pre> // Create some stuff</pre>
<pre>end;</pre>
<pre> </pre>
<pre>procedure TsvcSomeService.ServiceShutdown(Sender: TService);</pre>
<pre>begin</pre>
<pre> Stopped := True ;</pre>
<pre>end;</pre>
<pre> </pre>
<pre>-----Original Message-----</pre>
<pre>From: <a moz-do-not-send="true"
href="mailto:delphi-bounces@delphi.org.nz" target="_blank">delphi-bounces@delphi.org.nz</a> [<a
moz-do-not-send="true" href="mailto:delphi-bounces@delphi.org.nz"
target="_blank">mailto:delphi-bounces@delphi.org.nz</a>]</pre>
<pre>On Behalf Of Robert martin</pre>
<pre>Sent: Friday, 9 October 2009 10:34 a.m.</pre>
<pre>To: NZ Borland Developers Group - Delphi List</pre>
<pre>Subject: [DUG] basic Service question</pre>
<pre> </pre>
<pre>Hi</pre>
<pre> </pre>
<pre>I am trying to create a service 9never done this before) and following</pre>
<pre>some old instructions I found on the web. The suggest creating a</pre>
<pre>service then installing it with service.exe /install then adding code</pre>
<pre>and debuggin. I am failing at the most basic point. I am trying to</pre>
<pre>install on Vista from cmd line. It just comes up with a 'program is not</pre>
<pre>responding message.</pre>
<pre> </pre>
<pre>Any help would be appreciated :)</pre>
<pre>Rob</pre>
<pre> </pre>
<pre>_______________________________________________</pre>
<pre>NZ Borland Developers Group - Delphi mailing list</pre>
<pre>Post: <a moz-do-not-send="true"
href="mailto:delphi@delphi.org.nz" target="_blank">delphi@delphi.org.nz</a></pre>
<pre>Admin: <a moz-do-not-send="true"
href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a></pre>
<pre>Unsubscribe: send an email to <a moz-do-not-send="true"
href="mailto:delphi-request@delphi.org.nz" target="_blank">delphi-request@delphi.org.nz</a> with Subject:</pre>
<pre>unsubscribe</pre>
<pre> </pre>
<pre>No virus found in this incoming message.</pre>
<pre>Checked by AVG - <a moz-do-not-send="true"
href="http://www.avg.com" target="_blank">www.avg.com</a> </pre>
<pre>Version: 8.5.421 / Virus Database: 270.14.7/2422 - Release Date:</pre>
<pre>10/08/09 06:39:00</pre>
<pre> </pre>
<pre>_______________________________________________</pre>
<pre>NZ Borland Developers Group - Delphi mailing list</pre>
<pre>Post: <a moz-do-not-send="true"
href="mailto:delphi@delphi.org.nz" target="_blank">delphi@delphi.org.nz</a></pre>
<pre>Admin: <a moz-do-not-send="true"
href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a></pre>
<pre>Unsubscribe: send an email to <a moz-do-not-send="true"
href="mailto:delphi-request@delphi.org.nz" target="_blank">delphi-request@delphi.org.nz</a> with Subject: unsubscribe</pre>
<pre> </pre>
<pre> </pre>
<p><span style="font-size: 10pt; color: windowtext;">No
virus found in this incoming message.<br>
Checked by AVG - <a moz-do-not-send="true" href="http://www.avg.com"
target="_blank">www.avg.com</a><br>
Version: 8.5.421 / Virus Database: 270.14.7/2422 - Release Date:
10/08/09
06:39:00</span><span style="color: windowtext;"></span></p>
</div>
<pre><hr size="4" width="90%">
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: <a moz-do-not-send="true" href="mailto:delphi@delphi.org.nz"
target="_blank">delphi@delphi.org.nz</a>
Admin: <a moz-do-not-send="true"
href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a>
Unsubscribe: send an email to <a moz-do-not-send="true"
href="mailto:delphi-request@delphi.org.nz" target="_blank">delphi-request@delphi.org.nz</a> with Subject: unsubscribe</pre>
</blockquote>
</div>
<br>
_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a moz-do-not-send="true" href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a><br>
Admin: <a moz-do-not-send="true"
href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a moz-do-not-send="true"
href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a>
with Subject: unsubscribe<br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
Kyley Harris<br>
Harris Software<br>
+64-21-671-821<br>
</div>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: <a class="moz-txt-link-abbreviated" href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a>
Admin: <a class="moz-txt-link-freetext" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a>
Unsubscribe: send an email to <a class="moz-txt-link-abbreviated" href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject: unsubscribe</pre>
</blockquote>
</body>
</html>