怎样用条件得调用外部程序

来源:百度知道 编辑:UC知道 时间:2024/06/03 11:31:08
现在做了一个VB程序,用shell调用外部程序A。
我需要的是:
if 外部程序A运行中 then VB程序停止下一步的运行
如果 外部程序A运行结束 then VB程序就进行下一步的运行
请问该怎样写这段程序?谢谢!

P.S:(这个外部程序A运行后将运行的结果生成一个TXT文件,
运行这个外部程序A所需的时间比较长大约2个小时)

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function CreateFile Lib "KERNEL32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As String, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "KERNEL32" (ByVal hObject As Long) As Long
Private Const GENERIC_READ = &H80000000
Private Const GENERIC_WRITE = &H40000000
Private Const OPEN_EXISTING = 3
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const INVALID_HANDLE_VALUE = -1
Private Sub Command1_Click()
Dim RetVal
If Dir("c:\myfile.exe") <> "" And IsFileRun("c:\myfile.exe") Then '判断c盘的myfile.exe是否