
Why wait the end of a Shell process ?
Hope this helps!
--------------------------------------------------------
Option Compare Database
Const PROCESS_QUERY_INFORMATION = &H400
Const SYNCHRONIZE = &H100000
Const INFINITE = &HFFFFFFFF
Const STILL_ACTIVE = &H103&
Const ERR_FILE_NOT_FOUND = 53
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess
As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess
As Long, lpExitCode As Long) As Long
' Run an application, waiting for its completion
' before returning to the caller.
Dim hInstance As Long
Dim hProcess As Long
Dim lngRetval As Long
Dim lngExitCode As Long
On Error GoTo ahtRunAppWait_Err
' Start up the application.
hInstance = Shell(strCommand, intMode)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or SYNCHRONIZE, _
True, hInstance)
Do
' Attempt to retrieve the exit code, which will
' just not exist until the application has quit.
lngRetval = GetExitCodeProcess(hProcess, lngExitCode)
DoEvents
Loop Until lngExitCode <> STILL_ACTIVE
ahtRunAppWait_Exit:
Exit Sub
ahtRunAppWait_Err:
Select Case Err.Number
Case ERR_FILE_NOT_FOUND
MsgBox "Unable to find '" & strCommand & "'"
Case Else
MsgBox Err.Description
End Select
Resume ahtRunAppWait_Exit
End Sub
Quote:
> Hello,
> I use the commande Shell for calling the program FTP.EXE.
> But this operation is asyncronous
> Why can I wait the end of the shell command before continue my fonction
> ?
> thanks you !