View Full Version: Shutting down the computer

C++ Learning Community > C++ Tips > Shutting down the computer


Title: Shutting down the computer
Description: This won't always work but most of th...


Mastiff Odit - October 29, 2003 03:10 AM (GMT)
Pretty cool I'll try that one time when I don't have 5 programs running. (witch I normaly do)

Oh and to use: ExitWindowsEx(EWX_POWEROFF, SHTDN_REASON_MINOR_OTHER);

Do you need the include the windows.h file to your program?

TheHawgMaster - September 28, 2003 02:07 PM (GMT)
Most of the time (It won't if it's disabled on the computer) this will shut off the computer:
CODE
ExitWindowsEx(EWX_POWEROFF, SHTDN_REASON_MINOR_OTHER);
Just thought you might be interested to know.

that person - October 30, 2003 02:03 AM (GMT)
Another way is to include windows.h and use
CODE
//...
system("shutdown -t 5");
//  you can add -r to restart, and the 5 after t is how many seconds it waits.  There are also a couple other commands if you type 'shutdown /?' in dos.
//...


**EDIT: Oh yeah, and I don't think that this can be disabled either (unless after it pops up, you type 'shutdown -a' to abort it)

Consumed - November 25, 2003 02:51 AM (GMT)
I think you could also use InitiateSystemShutdown() . Never tried it though.

Dragon - November 25, 2003 05:59 AM (GMT)
TheHawgMaster, that's interesting to know. However, it's not very useful to me.

Incubator - November 25, 2003 04:57 PM (GMT)
system("halt"); //shutdown
system("reboot"); //reboot




* Hosted for free by InvisionFree