home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / autosh1a / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-06-20  |  5.2 KB  |  170 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Autoshut"
  5.    ClientHeight    =   3195
  6.    ClientLeft      =   4695
  7.    ClientTop       =   2970
  8.    ClientWidth     =   2130
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   3195
  13.    ScaleWidth      =   2130
  14.    Begin VB.CommandButton Command2 
  15.       Caption         =   "Deactivate"
  16.       Enabled         =   0   'False
  17.       Height          =   255
  18.       Left            =   0
  19.       TabIndex        =   8
  20.       Top             =   2880
  21.       Width           =   2055
  22.    End
  23.    Begin VB.CommandButton Command1 
  24.       Caption         =   "Activate"
  25.       Height          =   255
  26.       Left            =   0
  27.       TabIndex        =   7
  28.       Top             =   2520
  29.       Width           =   2055
  30.    End
  31.    Begin VB.Frame Frame1 
  32.       Caption         =   "Time To Shutdown:"
  33.       Height          =   615
  34.       Left            =   0
  35.       TabIndex        =   1
  36.       Top             =   0
  37.       Width           =   2055
  38.       Begin VB.TextBox Text1 
  39.          Height          =   285
  40.          Left            =   120
  41.          TabIndex        =   2
  42.          Top             =   240
  43.          Width           =   1815
  44.       End
  45.    End
  46.    Begin VB.Frame Frame2 
  47.       Caption         =   "Type:"
  48.       Height          =   1695
  49.       Left            =   0
  50.       TabIndex        =   0
  51.       Top             =   720
  52.       Width           =   2055
  53.       Begin VB.Timer Timer1 
  54.          Enabled         =   0   'False
  55.          Interval        =   1000
  56.          Left            =   840
  57.          Top             =   960
  58.       End
  59.       Begin VB.OptionButton optExitOption 
  60.          Caption         =   "Normal Shutdown"
  61.          Height          =   255
  62.          Index           =   0
  63.          Left            =   120
  64.          TabIndex        =   6
  65.          Top             =   240
  66.          Value           =   -1  'True
  67.          Width           =   1575
  68.       End
  69.       Begin VB.OptionButton optExitOption 
  70.          Caption         =   "Forced Shutdown"
  71.          Height          =   255
  72.          Index           =   3
  73.          Left            =   120
  74.          TabIndex        =   5
  75.          Top             =   1320
  76.          Width           =   1575
  77.       End
  78.       Begin VB.OptionButton optExitOption 
  79.          Caption         =   "Log Off"
  80.          Height          =   255
  81.          Index           =   2
  82.          Left            =   120
  83.          TabIndex        =   4
  84.          Top             =   960
  85.          Width           =   1575
  86.       End
  87.       Begin VB.OptionButton optExitOption 
  88.          Caption         =   "Reboot"
  89.          Height          =   255
  90.          Index           =   1
  91.          Left            =   120
  92.          TabIndex        =   3
  93.          Top             =   600
  94.          Width           =   1575
  95.       End
  96.    End
  97.    Begin VB.Menu mnuAboutItem 
  98.       Caption         =   "About..."
  99.    End
  100. Attribute VB_Name = "Form1"
  101. Attribute VB_GlobalNameSpace = False
  102. Attribute VB_Creatable = False
  103. Attribute VB_PredeclaredId = True
  104. Attribute VB_Exposed = False
  105. Option Explicit
  106. #If Win32 Then
  107.     Private Declare Function Shutdown Lib "user32" Alias "ExitWindowsEx" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
  108.     Private Const EWX_LOGOFF = 0
  109.     Private Const EWX_SHUTDOWN = 1
  110.     Private Const EWX_REBOOT = 2
  111.     Private Const EWX_FORCE = 4
  112. #Else
  113.     Private Declare Function Shutdown Lib "User" Alias "ExitWindows" (ByVal dwReturnCode As Long, ByVal wReserved As Integer) As Integer
  114.     Private Const EW_REBOOTSYSTEM = &H43
  115.     Private Const EW_RESTARTWINDOWS = &H42
  116. #End If
  117. Private SelectedOption As Integer
  118. Private Sub Command1_Click()
  119. Command1.Enabled = False
  120. Command2.Enabled = True
  121. Timer1.Enabled = True
  122. Text1.Enabled = False
  123. End Sub
  124. Private Sub Command2_Click()
  125. Command1.Enabled = True
  126. Command2.Enabled = False
  127. Timer1.Enabled = False
  128. Text1.Enabled = True
  129. End Sub
  130. Private Sub Form_Load()
  131.     #If Win32 Then
  132.         ' Prepare for 32 bit ExitWindowsEx.
  133.         optExitOption(0).Caption = "Normal Shutdown"
  134.         optExitOption(0).Tag = EWX_SHUTDOWN
  135.         optExitOption(1).Caption = "Reboot"
  136.         optExitOption(1).Tag = EWX_REBOOT
  137.         
  138.         optExitOption(2).Caption = "Log Off"
  139.         optExitOption(2).Tag = EWX_LOGOFF
  140.         
  141.         optExitOption(3).Caption = "Forced Shutdown"
  142.         optExitOption(3).Tag = EWX_FORCE
  143.     #Else
  144.         ' Prepare for 16 bit ExitWindows.
  145.         optExitOption(0).Caption = "Normal Shutdown"
  146.         optExitOption(0).Tag = 0
  147.         optExitOption(1).Caption = "Reboot"
  148.         optExitOption(1).Tag = EW_REBOOTSYSTEM
  149.         optExitOption(2).Caption = "Restart Windows"
  150.         optExitOption(2).Tag = EW_RESTARTWINDOWS
  151.         
  152.         optExitOption(3).Visible = False
  153.     #End If
  154.     Text1.Text = Time
  155. End Sub
  156. Private Sub mnuAboutItem_Click()
  157. Load Form2
  158. Form2.Show
  159. End Sub
  160. Private Sub Timer1_Timer()
  161. Dim CurrentTime
  162. CurrentTime = Format(Time, "hh:mm")
  163. If CurrentTime = Text1.Text Then
  164. Dim exit_option As Long
  165. exit_option = CLng(optExitOption(SelectedOption).Tag)
  166. Shutdown exit_option, 0
  167. Timer1.Enabled = False
  168. End If
  169. End Sub
  170.