1 2 procedure TForm1.Button1Click(Sender: TObject);
3 begin4 {use EWX_LOGOFF to log off5 use EWX_SHUTDOWN to shut down6 use EWX_REBOOT to reboot7 use EWX_FORCE to do a force command with a cobination of Power off, or Reboot or 8 shutdown or logoff9 use EWX_POWEROFF to power off10 }11 12 13 SetShutdownPrivilege(true) ;//set rights to use this pivrilege14 15 ifnot ExitWindowsEx(EWX_FORCE + EWX_POWEROFF , 0) then16 messagedlg('wasn''t able to shutdown PC!',mterror,[mbok],0);
17 18 SetShutdownPrivilege(false); //turn of rights19 end;