Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Public Const INFINITE = -1& Public Const SYNCHRONIZE = &H100000Private Sub Command1_Click() Dim i As Long Dim r As Long Dim p As Long i = Shell("NOTEPAD.EXE", vbNormalFocus) p = OpenProcess(SYNCHRONIZE, False, i) r = WaitForSingleObject(p, INFINITE) r = CloseHandle(p) MsgBox "Program Close" End Sub自己根据情况改改
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Const INFINITE = -1&
Public Const SYNCHRONIZE = &H100000Private Sub Command1_Click()
Dim i As Long
Dim r As Long
Dim p As Long
i = Shell("NOTEPAD.EXE", vbNormalFocus)
p = OpenProcess(SYNCHRONIZE, False, i)
r = WaitForSingleObject(p, INFINITE)
r = CloseHandle(p)
MsgBox "Program Close"
End Sub自己根据情况改改