by Arjang (3 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (15 Votes)
When you use the ExitWindowsEx API to reboot the system under Windows NT and Windows 2000, the machine does not reboot.
'CAUSE
In order to programmatically reboot a Windows NT or Windows 2000 system, the process requires the SE_SHUTDOWN_NAME privilege. By default, Visual Basic applications do not have this privilege and therefore will not reboot the machine.
In order to get ExitWindowsEx API to reboot the system under Windows NT or Windows 2000, the SE_SHUTDOWN_NAME privilege must be set.
This Code Shows you the best way to reboot force restart or shut down a PC
Assumes
N/A
Side Effects
Be carefull It will restart the machine.
API DeclarationsPrivate Declare Function ExitWindowsEx Lib "user32" (ByVal _
dwOptions As Long, ByVal dwReserved As Long) As Long