Attribute VB_Name = "Module3"
Option Explicit
'Determine 16-bit or 32-bit platform
#If Win32 Then
    Private Declare Function ShutdownWindows Lib "user32" Alias _
      "ExitWindowsEx" (ByVal uFlags As Long, _
      ByVal dwReserved As Long) As Long
#Else
    Private Declare Function ShutdownWindows Lib "user" Alias _
      "ExitWindows" (ByVal wReturnCode As Integer, _
      ByVal dwReserved As Integer) As Integer
#End If
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4

Function WinRestart() As Long
'*******************************************************
'<DESC>     Routine to Shutdown/Restart Windows
'       directory</DESC>
'<RETURN>   Long: determines whether windows
'       shutdown successfully
'<ACCESS>   Public
'<ARGS>     Integer: Shutdown Mode
'               </ARGS>
'<USAGE>    x = ShutdownWindows(EWX_REBOOT, 0)
'               </USAGE>
'*******************************************************
    Dim x As Integer
    Dim Response As Variant
    
    
      WinRestart = ShutdownWindows(EWX_REBOOT + EWX_FORCE, 0)
       

End Function

Function winrestartbck()
'*******************************************************
'<DESC>     Routine to Shutdown/Restart Windows
'       directory</DESC>
'<RETURN>   Long: determines whether windows
'       shutdown successfully
'<ACCESS>   Public
'<ARGS>     Integer: Shutdown Mode
'               </ARGS>
'<USAGE>    x = ShutdownWindows(EWX_REBOOT, 0)
'               </USAGE>
'*******************************************************
    Dim x As Integer
    Dim Response As Variant
    
    Response = MsgBox("This routine will Restart Windows!" & _
      vbCrLf & "Are you sure you want to do this?", vbYesNo + vbQuestion, _
      "Restart Windows?")
    If Response = vbYes Then
    'Cause Windows to Restart
    'If any programs refuse to terminate, this function will return ZERO
        x = ShutdownWindows(EWX_REBOOT, 0)
        If Not x Then
            Response = MsgBox("Some program(s) refused to terminate", _
          vbExclamation, "Cannot Restart Windows")
        End If
    End If

End Function


