This code will pause your app's thread until the shelled app closes.
[/code]
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 Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Const NORMAL_PRIORITY_CLASS = &H20&
Const INFINITE = -1&
Declare Function WaitForSingleObject Lib "kernel32" _
(Byval hHandle As Long, _
Byval dwMilliseconds As Long) As Long
Declare Function CreateProcessA Lib "kernel32" _
(Byval lpApplicationName As Long, _
Byval lpCommandLine As String, _
Byval lpProcessAttributes As Long, _
Byval lpThreadAttributes As Long, _
Byval bInheritHandles As Long, _
Byval dwCreationFlags As Long, _
Byval lpEnvironment As Long, _
Byval lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION) As Long
Declare Function GetExitCodeProcess Lib "kernel32" _
(Byval hProcess As Long, lpExitCode As Long) As Long
Declare Function CloseHandle Lib "kernel32" Alias "CloseHandle" (ByVal hObject As Long) As Long
'________________________________________
Function fShellWait(strCmdLine As String) As Long
'--- Shells the passed command line and waits for the process to finish
'--- Returns the exit code of the shelled process
Dim udtProc As PROCESS_INFORMATION
Dim udtStart As STARTUPINFO
Dim lngRtn As Long
'Initialize the STARTUPINFO structure
udtStart.cb = Len(udtStart)
'Launch the shelled application and yield to it
lngRtn = CreateProcessA(Clng(0), strCmdLine, CLng(0), _
CLng(0), CLng(1), NORMAL_PRIORITY_CLASS, CLng(0), _
CLng(0), udtStart, udtProc)
DoEvents
'Wait for the shelled application to finish
lngRtn = WaitForSingleObject(udtProc.hProcess, INFINITE)
GetExitCodeProcess udtProc.hProcess, lngRtn
CloseHandle udtProc.hThread
CloseHandle udtProc.hProcess
fShellWait = lngRtn
End Function
[/code]
Paul Bent
Northwind IT Systems