/// // Restart the computer // //////////////////////////////////
Int reboot ()
{
Handle htoken;
Token_privileges tkp;
// Get a token for this process.
If (! Openprocesstoken (getcurrentprocess (),
Token_adjust_privileges | token_query, & htoken ))
Printf ("openprocesstoken ");
// Get the luid for the shutdown privilege.
Lookupprivilegevalue (null, se_shutdown_name,
& Tkp. Privileges [0]. luid );
Tkp. privilegecount = 1; // One privilege to set
Tkp. Privileges [0]. Attributes = se_privilege_enabled;
// Get the shutdown privilege for this process.
Adjusttokenprivileges (htoken, false, & tkp, 0,
(Ptoken_privileges) null, 0 );
// Cannot test the return value of adjusttokenprivileges.
If (getlasterror ()! = Error_success)
Printf ("adjusttokenprivileges ");
// Restart
If (! Exitwindowsex (ewx_reboot | ewx_force, 0 ))
Printf ("exitwindowsex ");
Return 0;
}