用vb shell 先打开qq.exe 当qq.exe主动关闭的同时,如何让vb执行另外一个命令

来源:百度知道 编辑:UC知道 时间:2024/06/05 06:51:16
用vb shell 先打开qq.exe 当qq.exe主动关闭的同时,如何让vb执行另外一个命令

例如,我要实现 关闭qq.exe 的时候 打开 notepad.exe
或者,要实现 关闭的qq.exe 的时候,如何关闭已经打开的另外一个exe

谢谢

给你个示例,添加一个计时器,一个命令按钮,添加如下代码:
Dim fPath As String
Private Sub Command1_Click()
Shell fPath, vbNormalFocus
Timer1.Enabled = True
End Sub

Private Function IsRun(ByVal filename As String) As Boolean
On Error GoTo myerr
Dim mytempfile As String
mytempfile = App.Path + "\mytemp.bak"
FileCopy filename, mytempfile
Kill filename
IsRun = False
FileCopy mytempfile, filename
Kill mytempfile
Exit Function
myerr:
Select Case Err.Number
Case 75
Kill mytempfile
IsRun = True
Exit Function
Case Else
MsgBox Err.Description

End Select
End Function

Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.E