[DllImport("aygshell.dll", SetLastError=""true"")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ExitWindowsEx([MarshalAs(UnmanagedType.U4)]uint dwFlags, [MarshalAs(UnmanagedType.U4)]uint dwReserved);
[DllImport("aygshell.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ExitWindowsEx([MarshalAs(UnmanagedType.U4)] ExitWindowsAction uFlags, [MarshalAs(UnmanagedType.U4)] uint dwReserved);
Declare Function ExitWindowsEx Lib "aygshell.dll" (ByVal dwFlags As Integer, ByVal dwReserved As Integer) As Boolean
enum ExitWindowsAction : uint
{
EWX_LOGOFF = 0,
EWX_SHUTDOWN = 1,
EWX_REBOOT = 2,
EWX_FORCE = 4,
EWX_POWEROFF = 8
}
There is no alternative managed API function
Parameters:
uFlags
Specifies the type of shutdown. This parameter must be one of the following values:
EWX_POWEROFF - Shuts down the system and turns off the power. ""Note:"" This flag is not supported on a Windows Mobile-based Pocket PC.
EWX_REBOOT - Shuts down the system and reboots.
dwReserved
Reserved; this parameter is ignored
Available only at Windows Mobile 5.0 or later. The ExitWindowsEx function returns as soon as it has initiated the shutdown. The shutdown then proceeds asynchronously. Because the function executes asynchronously, a nonzero 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.
static void Main(string[] args)
{
ExitWindowsEx(ExitWindowsAction.EWX_REBOOT, 0);
}