🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10116

Re: Stopping a service from within itself

#10116
From: Remy Lebeau (TeamB)
Date: Sun, 16 May 2004 21:05
24 lines
1571 bytes
"Frank Gruber" <HVFDMIPUMFPS@spammotel.com> wrote in message
news:40a75e29@newsgroups.borland.com...

> 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().

That is one way to do it, but it is not the best way.

> PostThreadMessage(ServiceClass->ServiceThread->ThreadID,
> CM_SERVICE_CONTROL_CODE, SERVICE_CONTROL_STOP, 0);

The best way is to just call the service's Controller() method directly:

    void __fastcall TMyService::DoSomething()
    {
        //...
        this->Controller(SERVICE_CONTROL_STOP);
        //...
    }


Gambit
Technical Details
Message-ID: <40a7d8b1$1@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-mail
References: <40a75e29@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,c3caafa44ef41532
X-Google-Attributes: gid10cc67,public
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40a75e29@newsgroups.borland.com>
Subject: Re: Stopping a service from within itself
Date: Sun, 16 May 2004 14:05:01 -0700
Lines: 26
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.138.253
Message-ID: <40a7d8b1$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1084741809 67.22.138.253 (16 May 2004 14:10:09 -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