Const SYNCHRONIZE = &H100000
Const INFINITE = &HFFFFFFFF
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Sub Command1_Click()
Dim pId As Long, pHnd As Long ' 分别声明 Process Id 及 Process Handle 变数
Dim CVtemp As String, CVarray As Variant
pId = Shell(App.Path & "\1.Exe", vbNormalFocus) ' Shell 传回 Process Id
pHnd = OpenProcess(SYNCHRONIZE, 0, pId) ' 取得 Process Handle
If pHnd <> 0 Then
Call WaitForSingleObject(pHnd, INFINITE) ' 无限等待,直到程序结束
Call CloseHandle(pHnd)
MsgBox "OK"
End If
End Sub