I want my program could shutdown computer, I know how to suspend it, but How can I shutdown it?
Thanks.
Printable View
I want my program could shutdown computer, I know how to suspend it, but How can I shutdown it?
Thanks.
ExitWindowsEx ( EXW_SHUTDOWN, 0 );
will start a shutdown but will prompt the user whether to close any active applications - this gives the user the chance to cancel the shutdown.
ExitWindowsEx ( EXW_SHUTDOWN|EXW_FORCE, 0 );
does a shutdown, killing any active applications.
There is an additional snag if you're running on Windows NT. You have to set up the application's process token with permissions to allow you to shut down the PC.
The functions you'll need to look at are:
OpenProcessToken()
GetTokenInformation()
LookupPrivilegeValue()
AdjustTokenPrivileges()
If you're running on Windows 95/98, you don't have to worry about this.
Good luck!
Valerie Bradley
http://www.synthcom.com/~val
[email protected]