Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Restarting windows from c++

Reply
Thread Tools

Restarting windows from c++

 
 
CRE
Guest
Posts: n/a
 
      07-02-2004
Or more exactly, how does one access the windows API to do things like
shutdowns
?

--chris

--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      07-02-2004
On Thu, 01 Jul 2004 21:57:01 -0800, CRE <(E-Mail Removed)> wrote:

> Or more exactly, how does one access the windows API to do things like
> shutdowns
> ?
>


Your question is about the Windows API, not about C++. Ask in a Windows
programming group, news:comp.os.ms-windows.programmer.win32 for instance.
You are off topic here.

john
 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      07-02-2004
"CRE" <(E-Mail Removed)> wrote in message
newspsahxhb0nxqbskj@datamave-icwjaz...
> Or more exactly, how does one access the windows API to do things like
> shutdowns
> ?


One looks in the documentation for a Windows-targeted
implementation, which typically provides the API
reference, or visits www.msdn.microsoft.com, where
the API is documented.

Your query is not topical here.

Purpose of comp.lang.c++:
http://www.slack.net/~shiva/welcome.txt

Locating newsgroups about given topics:
www.groups.google.com


-Mike


 
Reply With Quote
 
JKop
Guest
Posts: n/a
 
      07-02-2004
CRE posted:

> Or more exactly, how does one access the windows API to do things like
> shutdowns
> ?
>
> --chris
>


#include <windows.h>

int main()
{
ExitWindowsEx(....
}


That's fun. But what's even more fun is getting into the device drivers for
the actual power, ie. electricity, to the computer, and just instantly
turning the computer off.

This if OFF-TOPIC, away with you to msnews.microsoft.com!


-JKOp
 
Reply With Quote
 
Rainer Hausbach
Guest
Posts: n/a
 
      07-02-2004
int main()
> {
> ExitWindowsEx(....
> }
>


IMHO W95/W98/ME only.
Win NT,W2k&XP need adjusted Rights.

Rainer


 
Reply With Quote
 
Unforgiven
Guest
Posts: n/a
 
      07-02-2004
"Rainer Hausbach" <(E-Mail Removed)> wrote in message
news:cc3d9v$63$(E-Mail Removed)...
> int main()
>> {
>> ExitWindowsEx(....
>> }
>>

>
> IMHO W95/W98/ME only.
> Win NT,W2k&XP need adjusted Rights.


Actually, this never works, at least not to shut down the system.

As you indicated, WinNT/2k/XP/2k3 need adjusted rights. You can however use
the code above to log off the current user without additional effort.
And while calling ExitWindowsEx to shut down is ok in Win9x, you can't
actually use it from a Console Application! ^_^

--
Unforgiven

 
Reply With Quote
 
JKop
Guest
Posts: n/a
 
      07-02-2004
Unforgiven posted:

> "Rainer Hausbach" <(E-Mail Removed)> wrote in message
> news:cc3d9v$63$(E-Mail Removed)...
>> int main()
>>> {
>>> ExitWindowsEx(....
>>> }
>>>

>>
>> IMHO W95/W98/ME only.
>> Win NT,W2k&XP need adjusted Rights.

>
> Actually, this never works, at least not to shut down the system.



Lies. Shutting down the system was all I ever did when I started out with
Win32 programming.


> As you indicated, WinNT/2k/XP/2k3 need adjusted rights. You can however
> use the code above to log off the current user without additional
> effort. And while calling ExitWindowsEx to shut down is ok in Win9x,
> you can't actually use it from a Console Application! ^_^


Lies. Win32 Console Applications have full access to dynamically linked
libraries, namely the Win32 API.


-JKop


 
Reply With Quote
 
Unforgiven
Guest
Posts: n/a
 
      07-02-2004
"JKop" <(E-Mail Removed)> wrote in message
news:CRcFc.3689$(E-Mail Removed)...
> Unforgiven posted:
>
>> "Rainer Hausbach" <(E-Mail Removed)> wrote in message
>> news:cc3d9v$63$(E-Mail Removed)...
>>> int main()
>>>> {
>>>> ExitWindowsEx(....
>>>> }
>>>>
>>>
>>> IMHO W95/W98/ME only.
>>> Win NT,W2k&XP need adjusted Rights.

>>
>> Actually, this never works, at least not to shut down the system.

>
>
> Lies. Shutting down the system was all I ever did when I started out with
> Win32 programming.
>
>
>> As you indicated, WinNT/2k/XP/2k3 need adjusted rights. You can however
>> use the code above to log off the current user without additional
>> effort. And while calling ExitWindowsEx to shut down is ok in Win9x,
>> you can't actually use it from a Console Application! ^_^

>
> Lies. Win32 Console Applications have full access to dynamically linked
> libraries, namely the Win32 API.


Then the Platform SDK is lying. From the documentation for ExitWindowsEx():
"To shut down or restart the system, the calling process must use the
AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege. For
more information, see Running with Special Privileges.
Windows Me/98/95: ExitWindowsEx does not work from a console application."
http://msdn.microsoft.com/library/en...twindowsex.asp

--
Unforgiven

 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      07-02-2004
"JKop" <(E-Mail Removed)> wrote in message
news:CRcFc.3689$(E-Mail Removed)...
> Unforgiven posted:


> Shutting down the system was all I ever did when I started out with
> Win32 programming.


LOL, same thing happened to me. Sometimes even required
a reinstall.

-Mike


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Restarting Windows service using an another application Stephen ASP .Net 2 03-01-2006 10:12 PM
Windows XP Restarting Jerald Montgomery Computer Support 9 06-23-2004 10:50 PM
Restarting Windows Jamie Computer Information 6 05-26-2004 04:38 PM
Windows 2000 Pro machine crashing and restarting when using Explorer, for example. Will Computer Support 1 05-19-2004 06:14 PM
Windows XP keeps restarting automatically before system finishes booting. GET ERROR: "We apologize for the inconveience but windows was not shutdown properly...." DaWurm Computer Support 3 11-15-2003 11:29 PM



Advertisments