# ExitWindowsEx Function

`Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long`

ExitWindowsEx shuts down or reboots the user's computer. The basic forms of it have the same effect as the options on the Windows Shut Down menu do. Of course, since the shutdown/reboot process will begin once the function is called, there won't normally be much left for your program to do. The function returns 0 if an error occured, or a non-zero value if successful.

uFlags
  One or more of the Exit Windows Flags specifying how to shut down or reboot the computer.
dwReserved
  Reserved for future versions of Windows. Always set to 0.

Example:

    ' This will reboot the user's computer
    x = ExitWindowsEx(EWX_REBOOT, 0)
    If x = 0 Then Debug.Print "Reboot process failed."

Category: Miscellaneous
Back to the index.