Option Explicit
Dim t, k As Integer
Private Declare Function SetSuspendState Lib "Powrprof" (ByVal Hibernate As Boolean, ByVal ForceCritical As Boolean, ByVal DisableWakeEvent As Boolean) As Boolean
Private Sub Command1_Click()
Shell "cmd.exe /c shutdown -l -t 1"
End Sub
Private Sub Command2_Click()
Shell "cmd.exe /c shutdown -r -t 1"
End Sub
Private Sub Command3_Click()
Shell "cmd.exe /c shutdown -s -t 1"
End Sub
Private Sub Command4_Click()
SetSuspendState False, False, False
End Sub
Private Sub Command5_Click()
If Command5.Caption = "定时关机" Then
Command5.Caption = "取消定时"
t = Val(Text1.Text) * 60
Timer1.Enabled = True
Else
If Command5.Caption = "取消定时" Then
Command5.Caption = "定时关机"
Timer1.Enabled = False
End If
End If
End Sub
Private Sub Command6_Click()
End
End Sub
Private Sub Form_Load()
Command1.Caption = "注销"
Command2.Caption = "重启"
Command3.Caption = "关机"
Command4.Caption = "待机"
Command5.Caption = "定时关机"
Command6.Caption = "取消"
Timer1.Interval = 1000
Timer1.Enabled = False
Label1.Caption = "定时关机"
End Sub
Private Sub Timer1_Timer()
t = t - 1
k = t \ 60
Label1.Caption = "系统将在" & Text1.Text & "分钟后关机!离关机还有" & k & "分钟"
If t = 0 Then
Timer1.Enabled = False
Call Command3_Click
End If
End Sub