Article View: borland.public.cppbuilder.nativeapi
Article #15191Re: Stop and startng a service
From: Giuliano
Date: Fri, 18 Jul 2003 09:36
Date: Fri, 18 Jul 2003 09:36
83 lines
3455 bytes
3455 bytes
On Thu, 17 Jul 2003 14:34:23 -0700, "Maurice Anderson"
<mauriceanderson@hotmail.com> wrote:
>Giuliano,
>
>Thanks. I am not sure what I am doing when I put FSCM( 0, "MyServiceName" )
>in the contructor heading. Maybe need to study up on that.
>
>1.) What is FSCM?
FSCM is the Field Service Control Manager, that is a instance
of the class TServiceControlManager.
>2.) Is there a way to instantiate it with the new keyword?
Of course. Possible scenarios are:
A) using contructor/destructor of your class
class TfrmMain : public TForm
{
__published: // IDE-managed Components
....
private: // User declarations
TServiceControlManager* const FSCM;
public: // User declarations
__fastcall TfrmMain(TComponent* Owner);
__fastcall ~TfrmMain() throw();
....
};
__fastcall TfrmMain::TfrmMain(TComponent* Owner)
: TForm(Owner), FSCM( new TServiceControlManager( 0, "MyServiceName" ) )
{
....
....
}
__fastcall TfrmMain::~TfrmMain() throw()
{
delete FSCM;
}
B) Using a smart pointer:
#include <memory>
class TfrmMain : public TForm
{
__published: // IDE-managed Components
....
private: // User declarations
const std::auto_ptr<TServiceControlManager> FSCM;
public: // User declarations
__fastcall TfrmMain(TComponent* Owner);
....
};
__fastcall TfrmMain::TfrmMain(TComponent* Owner)
: TForm(Owner), FSCM( new TServiceControlManager( 0, "MyServiceName" ) )
{
....
....
}
>3.) Will this code allow me to stop and start an existing service?
Yes. Just provide the correct service name. You can also avoid to stop
dependent services: call the stop function with the last parameter set to
false.
FSCM.stop( "w3svc", false ); // Stop IIS
>4.) For example, I wanted to stop and start the Tcpip service on
> a Windows 2000 workstation, how would I do this?
>
Simply you have to seek for the correct service name (browse the technet or
msdn site of M$ corp, or use the mmc services applet or type NET START from a
command line). Provide that name when you create the ServiceControlManager
instance.
Giuliano
Technical Details
Message-ID:
<3f19bb6b.7471904@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f163941$1@newsgroups.borland.com> <mdhchv8i6dsqrsemn6heka3sk41uj4cckg@4ax.com> <rghchv4m3v4qqrv0uqpg359inhsjm8i4kv@4ax.com> <3f17020b$1@newsgroups.borland.com> <8u2ehv8kjhckfkiijvbu2pq34p6pq5607m@4ax.com> <3f1715bd@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,80e98d9661a7c48a X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-18 02:40:08 PST From: gcardinali@remove_adhoc.net (Giuliano) Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Stop and startng a service Date: Fri, 18 Jul 2003 09:36:51 GMT Message-ID: <3f19bb6b.7471904@newsgroups.borland.com> References: <3f163941$1@newsgroups.borland.com> <mdhchv8i6dsqrsemn6heka3sk41uj4cckg@4ax.com> <rghchv4m3v4qqrv0uqpg359inhsjm8i4kv@4ax.com> <3f17020b$1@newsgroups.borland.com> <8u2ehv8kjhckfkiijvbu2pq34p6pq5607m@4ax.com> <3f1715bd@newsgroups.borland.com> X-Newsreader: Forte Agent 1.5/32.451 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 80.205.50.157 X-Trace: newsgroups.borland.com 1058520832 80.205.50.157 (18 Jul 2003 02:33:52 -0700) Lines: 83 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail