📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BackColor = &H80000004&
BorderStyle = 3 'Fixed Dialog
Caption = "关闭Windows"
ClientHeight = 2310
ClientLeft = 45
ClientTop = 330
ClientWidth = 4605
ControlBox = 0 'False
ForeColor = &H00000000&
Icon = "Form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 2310
ScaleWidth = 4605
StartUpPosition = 2 '屏幕中心
Begin VB.Timer Timer1
Interval = 1000
Left = 120
Top = 1440
End
Begin VB.CommandButton Command4
Caption = "关于"
Height = 255
Left = 3600
TabIndex = 7
Top = 2040
Width = 735
End
Begin VB.CommandButton Command3
Caption = "取消"
Height = 255
Left = 2640
TabIndex = 6
Top = 2040
Width = 735
End
Begin VB.CommandButton Command2
Caption = "预设"
Height = 255
Left = 1680
TabIndex = 5
Top = 2040
Width = 735
End
Begin VB.CommandButton Command1
Caption = "执行"
Height = 255
Left = 720
TabIndex = 4
Top = 2040
Width = 735
End
Begin VB.PictureBox Picture1
BackColor = &H80000004&
BorderStyle = 0 'None
Height = 495
Left = 120
Picture = "Form1.frx":0442
ScaleHeight = 495
ScaleWidth = 495
TabIndex = 3
Top = 240
Width = 495
End
Begin VB.ComboBox Combo1
BackColor = &H00800000&
ForeColor = &H00FFFFFF&
Height = 300
ItemData = "Form1.frx":0884
Left = 720
List = "Form1.frx":0886
Style = 2 'Dropdown List
TabIndex = 0
TabStop = 0 'False
Top = 360
Width = 3615
End
Begin VB.Frame Frame1
BackColor = &H80000004&
BorderStyle = 0 'None
Height = 1095
Left = 600
TabIndex = 8
Top = 960
Width = 3855
Begin VB.TextBox Text3
Height = 270
Left = 1560
TabIndex = 19
Text = "0"
Top = 480
Width = 615
End
Begin VB.TextBox Text2
Height = 270
Left = 2760
TabIndex = 18
Text = "0"
Top = 120
Width = 615
End
Begin VB.TextBox Text1
Height = 270
Left = 1560
TabIndex = 17
Text = "0"
Top = 120
Width = 615
End
Begin VB.CommandButton Command5
Caption = "重置"
Height = 255
Left = 2760
TabIndex = 15
Top = 480
Width = 615
End
Begin VB.CheckBox Check3
BackColor = &H80000004&
Caption = "定时报警"
Height = 180
Left = 0
TabIndex = 14
Top = 840
Width = 1335
End
Begin VB.CheckBox Check2
BackColor = &H80000004&
Caption = "定时执行操作"
Height = 255
Left = 0
TabIndex = 13
Top = 600
Width = 1575
End
Begin VB.CheckBox Check1
BackColor = &H80000004&
Caption = "倒计时执行操作"
Height = 255
Left = 0
TabIndex = 12
Top = 360
Width = 1575
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "秒"
Height = 255
Index = 2
Left = 2280
TabIndex = 16
Top = 600
Width = 495
End
Begin VB.Label Label4
AutoSize = -1 'True
BackColor = &H80000004&
Caption = "预设方法设置:"
Height = 180
Left = 120
TabIndex = 11
Top = 120
Width = 1260
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "分钟"
Height = 255
Index = 1
Left = 3360
TabIndex = 10
Top = 120
Width = 495
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "小时"
Height = 255
Index = 0
Left = 2280
TabIndex = 9
Top = 120
Width = 495
End
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "结束会话,关闭Windows,以便安全关闭电源。"
Height = 255
Left = 720
TabIndex = 2
Top = 720
Width = 3735
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "希望计算机如何操作"
Height = 255
Left = 720
TabIndex = 1
Top = 120
Width = 3255
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hwnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Const SHUTDOWN = 1
Const REBOOT = 2
Const LOGOFF = 0
Dim sh As Long
Dim counter As Integer
Dim n As Integer
Private Sub Check1_Click()
If Check1.Value = 1 Then
Label3(0).Caption = "小时"
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then
Label3(0).Caption = "点"
End If
End Sub
Private Sub Combo1_click()
Combo1.BackColor = &H800000
Combo1.ForeColor = &HFFFFFF
Select Case Combo1.ListIndex
Case 0
Label2.Caption = "结束会话,关闭Windows,以便安全关闭电源。"
Case 1
Label2.Caption = "结束会话,关闭Windows,然后重新启动。"
Case 2
Label2.Caption = "结束会话,用户重新登陆。"
End Select
End Sub
Private Sub Combo1_DropDown()
Combo1.BackColor = &HFFFFFF
Combo1.ForeColor = &H0
End Sub
Private Sub Command1_Click()
Dim str As String
If Command2.Enabled = True Then
Select Case Combo1.ListIndex
Case 0
shutdown1
Case 1
reboot1
Case 2
logoff1
End Select
Else
If Check1.Value = 0 And Check2.Value = 0 And Check3.Value = 0 Then
Select Case Combo1.ListIndex
Case 0
shutdown1
Case 1
reboot1
Case 2
logoff1
End Select
Else
If Check1.Value = 0 And Check2.Value = 0 Then
str = MsgBox("你还有设置漏选!", 48, "错误")
End If
End If
n = Val(Text1.Text) * 3600 + Val(Text2.Text) * 60 + Val(Text3.Text)
If Check2.Value = 1 Then
If Text1.Text = "" Then
Text1.Text = "0"
End If
If Text2.Text = "" Then
Text2.Text = "0"
End If
If Text3.Text = "" Then
Text3.Text = "0"
End If
End If
If Check1.Value = 1 Then
If Val(Text3.Text) > 60 Or Val(Text2.Text) > 60 Then
MsgBox "填入的数据错误,要重填!", 48, "错误"
n = 0
Exit Sub
End If
If Text1.Text <> "0" And Text2.Text = "0" Then
Text2.Text = "60"
End If
If Text2.Text <> "0" And Text3.Text = "0" Then
Text3.Text = "60"
End If
End If
Timer1.Enabled = True
End If
End Sub
Private Sub Command2_Click()
Dim str As String
If Combo1.Text = "" Then
str = MsgBox("请选择操作类型!", 0, "错误")
Exit Sub
End If
Frame1.Visible = True
Command2.Enabled = False
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Call ShellAbout(hwnd, "关闭Windows", "本软件由 HydeKong 制作!" & vbCrLf & "谢谢使用!", Me.Icon)
End Sub
Private Sub Command5_Click()
If Timer1.Enabled = True Then
Timer1.Enabled = False
End If
Text1.Text = 0
Text2.Text = 0
Text3.Text = 0
End Sub
Private Sub Form_Load()
Frame1.Visible = False
Label2.Caption = ""
Combo1.AddItem "关机"
Combo1.AddItem "重新启动"
Combo1.AddItem "注销"
counter = 0
Timer1.Enabled = False
End Sub
Private Sub shutdown1()
sh = ExitWindowsEx(SHUTDOWN, dwReserved)
End Sub
Private Sub reboot1()
sh = ExitWindowsEx(REBOOT, dwReserved)
End Sub
Private Sub logoff1()
sh = ExitWindowsEx(LOGOFF, dwReserved)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Key = Chr(KeyAscii)
If KeyAscii <> 8 And Key < "0" Or Key > "9" Then
MsgBox "请填入数字!"
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
Key = Chr(KeyAscii)
If KeyAscii <> 8 And Key < "0" Or Key > "9" Then
MsgBox "请填入数字!"
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
Key = Chr(KeyAscii)
If KeyAscii <> 8 And Key < "0" Or Key > "9" Then
MsgBox "请填入数字!"
End If
End Sub
Private Sub Timer1_Timer()
counter = counter + 1
If Check1.Value = 1 Then
If Text1.Text <> 0 And Text2.Text = "60" Then
Text1.Text = Text1.Text - "1"
End If
If Text2.Text <> 0 And Text3.Text = "60" Then
Text2.Text = Text2.Text - "1"
End If
If Text3.Text <> 0 Then
Text3.Text = Text3.Text - "1"
End If
If Text2.Text = "0" And Text1.Text <> "0" Then
Text2.Text = "60"
End If
If Text3.Text = "0" And Text2.Text <> "0" Then
Text3.Text = "60"
End If
End If
Dim ch As String
If Check3.Value = 1 Then
If n > 300 Then
If n - counter = 300 Then
Dim rtn
rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
ch = MsgBox("还有5分钟就要关机,是否继续执行?", 48 + vbYesNo, "提醒")
If ch = vbNo Then
Timer1.Enabled = False
rtn = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3)
counter = 0
Exit Sub
Else
MsgBox "请做好数据保存,就要关机了!", 48, "提醒"
End If
End If
End If
End If
If (n - counter) = 0 Then
Select Case Combo1.ListIndex
Case 0
shutdown1
Case 1
reboot1
Case 2
logoff1
End Select
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -