Article View: borland.public.cppbuilder.nativeapi
Article #16878Re: Stop/Uninstall service (Windows NT)
From: Remy Lebeau (TeamB)
Date: Wed, 23 Apr 2003 16:12
Date: Wed, 23 Apr 2003 16:12
34 lines
2494 bytes
2494 bytes
"Gnum" <mail@oscreator.com> wrote in message
news:3ea6b212@newsgroups.borland.com...
> Is there clever guy who knows what the ServiceApplication
> has to call to be stoped.
To stop itself? Just have the service call its Controller() method with the
SERVICE_CONTROL_STOP command:
this->Controller(SERVICE_CONTROL_STOP);
That will allow your service's OnStop event handler to trigger correctly,
assuming you have one. If you don't have one, or at least don't care if it
gets called, then you can just Terminate() the ServiceThread directly:
ServiceThread->Terminate();
> And what such application has to do to be uninstalled like
> "huba-buba.exe /uninstall" does, but inside ServiceThread?
A service can't uninstall itself directly. It must be invoked externally,
as the uninstall request is only processed once at process startup when it
first looks at the command-line parameters passed to it before setting up
the service for execution. Once the service is already up and running, it
is beyond the point where uninstall is possible. I suppose you could try
using CreateProcess() to spawn a secnd copy of the executable and pass it
the /uninstall and /silent command-line parameters, but I have not tried
that myself so I don't know what ll it will actually do. In theory, it
should just mark the service inside the SCM as having been deleted so other
processes can't use it anymore, and then will complete the rest of the
uninstall later on after the service has actually shut down.
Gambit
Technical Details
Message-ID:
<3ea6bb2d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3ea6b212@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,956b00d0acfec1b7 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-23 09:20:02 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3ea6b212@newsgroups.borland.com> Subject: Re: Stop/Uninstall service (Windows NT) Date: Wed, 23 Apr 2003 09:12:20 -0700 Lines: 36 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3ea6bb2d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1051114285 207.175.226.26 (23 Apr 2003 09:11:25 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail