AbortSystemShutdown (advapi32)
Last changed: -37.160.138.42

.
Summary
The AbortSystemShutdown function stops a system shutdown that has been initiated.

C# Signature:

[DllImport("advapi32.dll")] static extern bool AbortSystemShutdown(String lpMachineName);

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

Please add some!

Tips & Tricks:

Please add some!

Sample Code:

  [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");
  }

Documentation