' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiExitWindowsEx Lib "user32" _
Alias "ExitWindowsEx" _
(ByVal uFlags As Long, ByVal dwReserved As Long) _
As Long
Public Const EWX_FORCE = 4 'Forcibly terminates processes
'that do not respond.
Public Const EWX_LOGOFF = 0 'Terminates processes, then logs off.
Public Const EWX_SHUTDOWN = 1 'Powers the system off, if possible.
Public Const EWX_REBOOT = 2 'Reboots the system.
Function fTerminateWin(lngExitVal As Long)
fTerminateWin = apiExitWindowsEx(lngExitVal, 0)
End Function
Sub test()
fTerminateWin (4) 'Only 4 and 0 work on my machine
End Sub