In Delphi, I started a program (FTP) with ShellExecute. Then I want to wait until the FTP process ends and continue the following operations. How can I monitor whether the process has ended? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiAPI/html/delphi_20061115114909229.html
Example:
Hinstance: = ShellExecute (application. Handle, nil, pchar ('ftp '), pchar ('-I-n-s: '+ scriptname), nil, sw_shownormal );
For I: = 0 to 10 do
Begin
Sleep 1000;
If ftp_end () then
Break;
End;
Use OpenProcess with waitforsingleobject.
Transferred
Execute an external Program And wait for it to finish.
Function winexecexw (CMD, workdir: pchar; visiable: integer): DWORD;
VaR
Startupinfo: tstartupinfo;
Processinfo: tprocessinformation;
Begin
Fillchar (startupinfo, sizeof (startupinfo), #0 );
Startupinfo. CB: = sizeof (startupinfo );
Startupinfo. dwflags: = startf_useshowwindow;
Startupinfo. wshowwindow: = visiable;
If not CreateProcess (nil, CMD, nil, nil, false, create_new_console or normal_priority_class, nil, nil, startupinfo, processinfo) then
Result: = 0
Else
Begin
Waitforsingleobject (processinfo. hprocess, infinite );
Getexitcodeprocess (processinfo. hprocess, result );
End;
End;
The waitforsingleobject function seems to have a problem in XP and will wait for it all the time. I am afraid to use it now ;;
Shellexectue returns the Process Handle. In theory, hinstance can be used to check its status, but it does not know how to do it!
It is better to use tidftp on your own.