Beispiel #1
0
 /// <summary>
 /// Used to logoff, shutdown or reboot.
 /// </summary>
 /// <param name="flags">The type of exit to perform.</param>
 /// <param name="reasons">The reason for the exit.</param>
 /// <returns><c>true</c> if successful, otherwise <c>false</c>.</returns>
 public static bool WindowsExit(ExitWindows flags, ShutdownReasons reasons)
 {
   EnableToken("SeShutdownPrivilege");
   return ExitWindowsEx((int)flags, (int)reasons) != 0;
 }
 public static extern UInt32 InitiateShutdown(
     string lpMachineName,          //The name of the computer to be shut down. If the value of this parameter is NULL, the local computer is shut down.
     string lpMessage,              //The message to be displayed in the interactive shutdown dialog box.
     UInt32 dwGracePeriod,          //The number of seconds to wait before shutting down the computer.
     ShutdownFlags dwShutdownFlags, //One or more bit flags that specify options for the shutdown.
     ShutdownReasons dwReason);     //The reason for initiating the shutdown.
Beispiel #3
0
        public static void ExitWindowsEx(ShutdownMethods shutdownMethod, ForceShutdownMethods forceOptions, ShutdownReasons shutdownReason)
        {
            var method = (uint)shutdownMethod | (uint)forceOptions;

            if (!NativeMethods.ExitWindowsEx(method, shutdownReason))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error(), "ExitWindowsEx failed");
            }
        }
Beispiel #4
0
 internal static extern bool ExitWindowsEx(ShutdownFlags uFlags, ShutdownReasons dwReason);
Beispiel #5
0
 internal static extern bool ExitWindowsEx(uint shutdownMethod, ShutdownReasons shutdownReasons);