[DllImport("advapi32.dll")] static extern bool AbortSystemShutdown(String lpMachineName);
Do you know one? Please contribute it!
Please add some!
Please add some!
[DllImport("ntdll.dll", SetLastError = true)]
public static extern IntPtr RtlAdjustPrivilege(int Privilege, bool bEnablePrivilege, bool IsThreadPrivilege, out bool PreviousValue);
[DllImport("advapi32.dll")] static extern bool
AbortSystemShutdown(String lpMachineName);
int SeShutdownPrivilege = 19;
bool PreviousValue = false;
IntPtr STATUS_SUCCESS = new IntPtr(0);
if(RltAdjustPrivilege(SeShutdownPrivilege, true, false, out PreviousValue) == STATUS_SUCCESS){ //Sets privileges to abort shutdown
if(!AbortSystemShutdown(null)){ //Abort the system shutdown of the local machine
throw new Exception("Could not abort system shutdown");
}
} else{
throw new Exception("Could not set the SeShutdownPrivilege");
}