AdvApi32InitiateShutdown Method

Initiates a shutdown and restart of the specified computer, and restarts any applications that have been registered for restart.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("AdvApi32.dll", CharSet = CharSet.Auto, BestFitMapping = false, 
	ThrowOnUnmappableChar = true, SetLastError = true)]
public static uint InitiateShutdown(
	string machineName,
	string message,
	int gracePeriod,
	uint shutdownFlags,
	uint reason
)

Parameters

machineName  String
The name of the computer to be shut down.

If the value of this parameter is , the local computer is shut down. This parameter can be an addres, for example: 127.0.0.1

message  String
The message to be displayed in the interactive shutdown dialog box.
gracePeriod  Int32
The number of seconds to wait before shutting down the computer.

If the value of this parameter is zero, the computer is shut down immediately. This value is limited to MAX_SHUTDOWN_TIMEOUT.

If the value of this parameter is greater than zero, and the shutdownFlags parameter specifies the flag GRACE_OVERRIDE, the function fails and returns the error code ERROR_BAD_ARGUMENTS.

shutdownFlags  UInt32
Specifies options for the shutdown.
reason  UInt32
The reason for initiating the shutdown.

If this parameter is zero, the default is an undefined shutdown that is logged as "No title for this reason could be found". By default, it is also an 'unplanned' shutdown.

Return Value

UInt32
If the function succeeds, it returns ERROR_SUCCESS.

Remarks

See Also