📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "在不同的模式下实现定时关闭计算机"
ClientHeight = 2520
ClientLeft = 60
ClientTop = 345
ClientWidth = 4320
LinkTopic = "Form1"
ScaleHeight = 2520
ScaleWidth = 4320
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton Command2
Caption = "取消定时关机"
Height = 390
Left = 1470
TabIndex = 5
Top = 1980
Width = 1365
End
Begin VB.CommandButton Command3
Caption = "退出"
Height = 390
Left = 2835
TabIndex = 3
Top = 1980
Width = 1365
End
Begin VB.TextBox Text1
Height = 330
Left = 765
TabIndex = 2
Top = 810
Width = 1290
End
Begin VB.Timer Timer1
Interval = 800
Left = 0
Top = 285
End
Begin VB.CommandButton Command1
Caption = "启动定时关机"
Height = 390
Left = 105
TabIndex = 0
Top = 1980
Width = 1365
End
Begin VB.Label Label3
Height = 390
Left = 345
TabIndex = 6
Top = 1425
Width = 3570
End
Begin VB.Label Label2
Caption = "设置 分钟后关闭计算机"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
Left = 195
TabIndex = 4
Top = 855
Width = 4050
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 315
TabIndex = 1
Top = 90
Width = 3795
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const SM_CLEANBOOT = 67
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, _
ByVal dwReserved As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim mytime As Date
Dim RUNTIME As Long
Private Sub Timer1_Timer()
Dim HOUR As Integer
Dim MIN As Integer
Dim SEC As Integer
Dim RUN As String
Dim delay As Integer
RUNTIME = GetTickCount() \ 1000
HOUR = Int(RUNTIME \ 3600)
MIN = (RUNTIME - 3600 * HOUR) \ 60
SEC = RUNTIME - 3600 * HOUR - 60 * MIN
RUN = HOUR & ":" & MIN & ":" & SEC
Select Case GetSystemMetrics(SM_CLEANBOOT)
Case 1: Label1.Caption = "安全模式已运行" & Format(RUN, "hH:Mm:Ss")
Case 2: Label1.Caption = "网络安全模式已运行" & Format(RUN, "hH:Mm:Ss")
Case Else: Label1.Caption = "正常模式已运行" & Format(RUN, "hH:Mm:Ss")
End Select
delay = (Val(Text1.Text) - RUNTIME \ 60 + mytime \ 60)
If Text1.Enabled = False Then
Label3.Caption = "距离关闭计算机还有 " & delay & " 分钟"
If delay = 0 Then Call ExitWindowsEx(EWX_SHUTDOWN, 0)
End If
End Sub
Private Sub Command1_Click()
If Val(Text1.Text) * 60 > 60 Then
Text1.Enabled = False
mytime = RUNTIME
Else
MsgBox ("请输入关机时间,时间要大于1分钟!")
End If
End Sub
Private Sub Command2_Click()
Text1.Enabled = True
End Sub
Private Sub Command3_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -