Flora Edwards
asked on
Force Shutdown does not work
i found the below code from google. only 0 and 4 works which 0 is normal log off and 4 is forced log off.
how this code altered so that it works in Force Shutdown and Force Restart?
how this code altered so that it works in Force Shutdown and Force Restart?
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 (2) 'Only 4 and 0 work on my machine
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.