📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Visible = 0 'False
Begin VB.Timer Timer2
Interval = 1000
Left = 2880
Top = 1800
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 1000
Left = 1800
Top = 1320
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim id As Long
Public Function GetJingCheng(Exename As String) As String ' \取得进程
Dim theloop As Long
Dim proc As PROCESSENTRY32
Dim snap As Long
Dim Lent As Integer
Lent = Len(Exename)
GetJingCheng = "" '清空所有内容
snap = CreateToolhelpSnapshot(TH32CS_SNAPall, 0) '获得进程“快照”的句柄
proc.dwSize = Len(proc)
theloop = ProcessFirst(snap, proc) '获取第一个进程,并得到其返回值
While theloop <> 0 '当返回值非零时继续获取下一个进程
If Left(proc.szExeFile, Lent) = Exename Then
GetJingCheng = proc.th32ProcessID
End If
theloop = ProcessNext(snap, proc)
Wend
CloseHandle snap '关闭进程“快照”句柄
End Function
Private Sub Form_Load()
App.TaskVisible = False
HideCurrentProcess
End Sub
Private Sub Timer1_Timer()
id = Val(GetJingCheng("机房管理系统客户端.exe"))
If id <> 0 Then
Else
'Shell App.Path & "\..\机房管理系统客户端.exe", vbNormalFocus
'强制关机
ShutDownPC
End If
End Sub
Private Sub Timer2_Timer() '此时钟控件用于使监控在15秒后起作用,因为链接SQL数据库最多需要15秒钟
I = I + 1
If I >= 30 Then Timer1.Enabled = True: Timer2.Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -