Article View: borland.public.cppbuilder.nativeapi
Article #10115Stopping a service from within itself
From: Frank Gruber
Date: Sun, 16 May 2004 12:30
Date: Sun, 16 May 2004 12:30
13 lines
1372 bytes
1372 bytes
I post this here if others will face the same problem to get a solution. The solutions I found on the net so far suggests to call ServiceClass->ServiceThread->Terminate(). I was wondering why this did not work for my service app. Looking at the source code shows why. This solution only works if you build your service by using the OnExecute event handler. If you use the OnStart event handler you can use the following code: PostThreadMessage(ServiceClass->ServiceThread->ThreadID, CM_SERVICE_CONTROL_CODE, SERVICE_CONTROL_STOP, 0); Frank.
Technical Details
Message-ID:
<40a75e29@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,c3caafa44ef41532,start X-Google-Attributes: gid10cc67,public From: "Frank Gruber" <HVFDMIPUMFPS@spammotel.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Stopping a service from within itself Date: Sun, 16 May 2004 14:30:04 +0200 Lines: 15 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4927.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 NNTP-Posting-Host: 217.225.14.10 Message-ID: <40a75e29@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1084710441 217.225.14.10 (16 May 2004 05:27:21 -0700) Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail