🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Stopping proccesses, rebooting, etc, in windows XP

#15373
From: James A Beggs
Date: Tue, 08 Jul 2003 13:50
41 lines
2379 bytes
Sorry, do you mean the sdks for, say, the windows XP OS if thats what its
for?



"Max Topley" <mtj2@btopenworld.com> wrote in message
news:d23kgvoi398a4rd4t75o6iei30lgpufsjc@4ax.com...
> On Mon, 7 Jul 2003 16:50:08 -0500, James A Beggs wrote:
>
> >I've just been asked to design some code that will shut down a pair of
> >services running on a computer, delete files in a directory, then reboot
the
> >computer.
>
> You need to read up on Services and the Service Control Manager in the
> Platform SDK help files. Take careful note of any dependencies in the
> services you are dealing with.
>
> The following snippet shows how to stop a service (error checking etc.
> removed):
>
> //-----------------------------
> SC_HANDLE schService, schSCManager;
> SERVICE_STATUS ssStatus;
>
> schSCManager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS);
> schService = OpenService( schSCManager,
> TEXT( "ServiceName"), SERVICE_STOP) ;
> if ( schService != NULL )
>   ControlService( schService, SERVICE_CONTROL_STOP, &ssStatus) ;
> //-----------------------------
>
> You can use the ExitWindowsEx API function to reboot - e.g.:
>
> ExitWindowsEx( EWX_REBOOT | EWX_FORCE, 0) ;
>
> (Note: in Win2000/XP, it's kinder to use EWX_FORCEIFUNG rather than
> EWX_FORCE)
>
> --
>   Max
Technical Details
Message-ID: <3f0aca91$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f09e987@newsgroups.borland.com> <d23kgvoi398a4rd4t75o6iei30lgpufsjc@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,911e287f8b4b0d34
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-08 07:10:48 PST
From: "James A Beggs" <jbeggs@aqha.org>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f09e987@newsgroups.borland.com> <d23kgvoi398a4rd4t75o6iei30lgpufsjc@4ax.com>
Subject: Re: Stopping proccesses, rebooting, etc, in windows XP
Date: Tue, 8 Jul 2003 08:50:18 -0500
Lines: 43
Organization: American Quarter Horse Association
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: 12.19.120.242
Message-ID: <3f0aca91$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1057671825 12.19.120.242 (8 Jul 2003 06:43:45 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail