Puedes lanzar un "Shell sincrono". Es decir, que tu programa se quede "clavado" mientras el primer Shell todavía se esta ejecutando.
La función de llamada:
'Ejecutar el programa de instalación
PID = Shell(strCmd, vbNormalFocus)
If PID <> 0 Then
'Esperar a que finalice
WaitForTerm PID
End If
En un módulo:
Global Const SYNCHRONIZE = &H100000
Global Const INFINITE = &HFFFFFFFF
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Sub WaitForTerm(ByVal PID As Long)
On Error GoTo Gestion_Error
'Variables locales
Dim phnd As Long
phnd = OpenProcess(SYNCHRONIZE, 0, PID)
If phnd <> 0 Then
Call WaitForSingleObject(phnd, INFINITE)
Call CloseHandle(phnd)
End If
Exit Sub
Gestion_Error:
Call MsgBox(Err.Number & ": " & Err.Description)
End Sub
NOTA: En la llamada a WaitForSingleObject, en lugar de poner INFINITE, puedes poner los milisegundos que, como máximo, quieres que espere tu programa a la finalización del proceso. En ese caso, si no acaba, también queda liberado tu programa al cabo de esos milisegundos.
Publicado en es.comp.lenguajes.visual-basic por Alex Martínez
Posted
mar, sep 21 1999 22:48
by
Maverick