🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages Started by Gnum Wed, 23 Apr 2003 15:32
Stop/Uninstall service (Windows NT)
#16877
Author: Gnum
Date: Wed, 23 Apr 2003 15:32
8 lines
1201 bytes
Is there clever guy who knows what the ServiceApplication has to call to be
stoped.
And what such application has to do to be uninstalled like "huba-buba.exe
/uninstall" does, but inside ServiceThread?

Thanks a lot!

Gnum
Re: Stop/Uninstall service (Windows NT)
#16878
Author: Remy Lebeau (TeamB)
Date: Wed, 23 Apr 2003 16:12
34 lines
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
Re: Stop/Uninstall service (Windows NT)
#16782
Author: Gnum
Date: Wed, 23 Apr 2003 17:34
4 lines
1031 bytes
Thanks, Remy!
I found that I use the right way!

Gnum
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads