Procedure DesligaWindows(Reboot:Boolean); { Para Windows XP} var
nov,ant:TOKEN_PRIVILEGES;
C,Tok:Cardinal; begin
OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY,Tok);
LookupPrivilegeValue('','SeShutdownPrivilege',ant.Privileges[0].Luid);
ant.PrivilegeCount:=1; nov.PrivilegeCount:=1;
nov.Privileges[0].Luid:=ant.Privileges[0].Luid;
nov.Privileges[0].Attributes:=SE_PRIVILEGE_ENABLED; if AdjustTokenPrivileges(Tok,false,nov,16,ant,C)then if Reboot then ExitWindowsEx(EWX_REBOOT+EWX_FORCE,0) else ExitWindowsEx(EWX_SHUTDOWN+EWX_FORCE,0); end;