'***************************************************
'
'  This program shuts down your PC after 5 minutes
'  of switching  on if kept in start of windows
'
'   Programmed by Deepak Mehtani
'   Mail me at : [email protected]
'
'***************************************************'********************************'
'Double Click time to enable exit'
'********************************'Private Const EWX_SHUTDOWN As Long = 1
Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As LongDim Hrs
Dim Mnt
Dim AMPM
Dim SetAlarmPrivate Sub cmdCurrent_Click()
    MsgBox SetAlarm, , "Current Alarm Time"
End SubPrivate Sub cmdQuit_Click()
    End
End SubPrivate Sub cmdSet_Click()
   Dim h, m, nh, nm
    h = Hour(Time)
    If h > 12 Then
      h = h - 12
      optPM.Value = True
    Else
      optAM.Value = True
    End If
    m = Minute(Time)
    nm = m + 5
    If nm > 59 Then
       nm = nm - 59
       nh = h + 1
       If nh > 12 And AMPM = "AM" Then
          nh = nh - 12
          AMPM = "PM"
       ElseIf nh > 12 And AMPM = "PM" Then
          nh = nh - 12
          AMPM = "AM"
       End If
    Else
      nh = h
    End If
    txtHours.Text = nh
    If nm > 10 Then
       txtMinutes.Text = nm
    Else
       txtMinutes.Text = "0" & nm
    End If
    Hrs = txtHours.Text
    Mnt = txtMinutes.Text
    If optAM.Value = True Then
        AMPM = "AM"
    ElseIf optPM.Value = True Then
        AMPM = "PM"
    End If    SetAlarm = Hrs + ":" + Mnt + ":00 " + AMPM
End SubPrivate Sub Form_Load()
    Me.Top = (Screen.Height - Me.Height) / 2
    Me.Left = (Screen.Width - Me.Width) / 2
    Call cmdSet_Click
End SubPrivate Sub lblTime_DblClick()
cmdQuit.Enabled = True
End SubPrivate Sub Timer1_Timer()
    lblTime.Caption = Time   ' Update time display.
    If SetAlarm = lblTime.Caption Then
        'shut down the computer
        lngResult = ExitWindowsEx(EWX_SHUTDOWN, 0&)
    End If
End Sub