Option Explicit
Private Declare Function CreateProcess Lib "Kernel32" Alias _
"CreateProcessA" ( _
ByVal lpAppName As Long, _
ByVal lpCmdLine As String, _
ByVal lpProcAttr As Long, _
ByVal lpThreadAttr As Long, _
ByVal lpInheritedHandle As Long, _
ByVal lpCreationFlags As Long, _
ByVal lpEnv As Long, _
ByVal lpCurDir As Long, _
lpStartupInfo As STARTUPINFO, _
lpProcessInfo As PROCESS_INFORMATION _
) 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 Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Integer
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Public Function ShellWait(CmdLine As String, Optional ByVal _
bShowApp As Boolean = False) As Boolean
Dim uProc As PROCESS_INFORMATION
Dim uStart As STARTUPINFO
Dim lRetVal As Long
uStart.cb = Len(uStart)
uStart.wShowWindow = Abs(bShowApp)
uStart.dwFlags = 1
lRetVal = CreateProcess(0&, CmdLine, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, _
uStart, uProc)
lRetVal = WaitForSingleObject(uProc.hProcess, INFINITE)
lRetVal = CloseHandle(uProc.hProcess)
lRetVal = CloseHandle(uProc.hThread)
ShellWait = (lRetVal <> 0)
End Function
Saludos.