VB同时执行多条dos命令后,怎么监控这些dos命令都运行完毕,再执行下一条命令?

2024-11-24 20:22:51
推荐回答(2个)
回答1:

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Sub Form_Load()
Dim lngPId As Long
Dim lngPHandle As Long
lngPId = Shell("Notepad.exe", vbNormalFocus)
lngPHandle = OpenProcess(SYNCHRONIZE, 0, lngPId)
If lngPHandle = 0 Then
Call WaitForSingleObject(lngPHandle, INFINITE) ' 无限等待, 直到程式结束
Call CloseHandle(lngPHandle)
End If
Call Shell("d:\test3\select.exe", vbHide)
End Sub

回答2:

应该不冲突吧 你只管执行就没问题吧....楼上正解