属性Interval是时间间隔为
10000微秒即(1秒)看下当启动程序时执行timer事件private
sub
timer()static
x
integer
'为static的意义是时钟每执行一次就会定义一次,在VB中定义初值是0
所以static
保持上次数.x=x+1if
x==60
then
endEnd
sub
'便宜你了Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim a, b, hwndd
Private Sub Command1_Click()
a = InputBox("请输入要关闭的程序进程名, (不包括.EXE)", "输入")
b = InputBox("请输入要关闭的程序名", "输入")
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Command1.Caption = "检测程序"
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If Len(a) >1 Then
Form1.Cls
Print Now
Print "启动监视程序"
Print "监视程序为" &a
Print "正在监视..."
hwndd = FindWindow(vbNullString, b)
If hwnd = 1 Then
Print "检测到程序启动"
Print "正在结束进程..."
Shell "tskill " &a
Else
Print "未检测到程序启动"
End If
Else
Form1.Cls
Print Now
Print "启动监视程序"
Print "监视程序为" &a
Print "正在监视..."
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)