Doevents
WaitForSingleObject
Public Function ShellSync( _ ByVal PathName As String, _ ByVal WindowStyle As VbAppWinStyle) As Long 'Shell and wait. Return exit code result, raise an 'exception on any error. Dim lngPid As Long Dim lngHandle As Long Dim lngExitCode As Long lngPid = Shell(PathName, WindowStyle) If lngPid <> 0 Then lngHandle = OpenProcess(SYNCHRONIZE _ Or PROCESS_QUERY_INFORMATION, 0, lngPid) If lngHandle <> 0 Then WaitForSingleObject lngHandle, INFINITE If GetExitCodeProcess(lngHandle, lngExitCode) <> 0 Then ShellSync = lngExitCode CloseHandle lngHandle Else CloseHandle lngHandle Err.Raise &H8004AA00, "ShellSync", _ "Failed to retrieve exit code, error " _ & CStr(Err.LastDllError) End If Else Err.Raise &H8004AA01, "ShellSync", _ "Failed to open child process" End If Else Err.Raise &H8004AA02, "ShellSync", _ "Failed to Shell child process" End If End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)