判断一个程序启动完成(不是结束) '将以下代码加入标准模块 Option Explicit public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long public Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long public Const PROCESS_QUERY_INFORMATION = &H400 public Const STATUS_PENDING = &H103& '在需要的地方调用RunShell过程,如:res=RunShell("c:\windows\notepad.exe") '返回值为真则程序结束 Public Function RunShell(cmdline As String) As Boolean Dim hProcess As Long Dim ProcessId As Long Dim exitCode As Long ProcessId = Shell(cmdline, 1) hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId) Do Call GetExitCodeProcess(hProcess, exitCode) DoEvents Loop While exitCode = STATUS_PENDING Call CloseHandle(hProcess) RunShell = True End Function