User32ExitWindowsEx Method

Logs off the interactive user, shuts down the system, or shuts down and restarts the system.

It sends the WM_QUERYENDSESSION message to all applications to determine if they can be terminated.

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("User32.dll", SetLastError = true)]
public static bool ExitWindowsEx(
	ExitwindowsExFlags flags,
	ShutdownReason reason
)

Parameters

flags  ExitwindowsExFlags
The shutdown type.
reason  ShutdownReason
The reason for initiating the shutdown.

Return Value

Boolean
If the function succeeds, the return value is .

The function executes asynchronously so a return value indicates that the shutdown has been initiated.

It does not indicate whether the shutdown will succeed. It is possible that the system, the user, or another application will abort the shutdown.

If the function fails, the return value is .

Remarks

See Also