include("../include.php"); writeHeader("Shutdown, reboot or logoff windows", "Programming » Visual Basic 6 » Visual Basic 6 Code » Windows API » ");?>
' If the function returns you can assume that another application refused ' to terminate. The EWX_FORCE option can be used to attempt to force the ' issue. Const EWX_FORCE = 4 Const EWX_LOGOFF = 0 Const EWX_REBOOT = 2 Const EWX_SHUTDOWN = 1 Declare Function ExitWindowsEx Lib "user32" _ (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Function RestartWindows() As Boolean RestartWindows = CBool(ExitWindowsEx(EWX_REBOOT, 0)) End Function Function ShutDownPC() As Boolean ShutDownPC = CBool(ExitWindowsEx(EWX_SHUTDOWN, 0)) End Function Function LogOffPC() As Boolean ShutDownPC = CBool(ExitWindowsEx(EWX_LOGOFF, 0)) End Function