Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ShellExecute and then Wait?

69 views
Skip to first unread message

Abram Weas

unread,
Nov 16, 1999, 3:00:00 AM11/16/99
to
I am using ShellExecute to copy files from one machine to another using DOS'
xcopy.exe. However, I need to know when the copy is complete. Is there a
way to run ShellExecute and wait for the external program to complete its
task before going on.

Thanx,
Abram Weas


Ronny Lange

unread,
Nov 16, 1999, 3:00:00 AM11/16/99
to Abram Weas
Abram Weas schrieb:


If you want to wait for the executed program try this function :

{---------------------------------------------------------------------------}
function WaitforProgram(name : string) : boolean;
var
StartUpInfo : TStartUpInfo;
ProcessInfo : TProcessInformation;
begin
FillChar(StartUpInfo,SizeOf(StartupInfo),0);

with StartupInfo do
begin
cb := SizeOf(StartupInfo);
dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
wShowWindow := SW_SHOWNORMAL;
end;
if CreateProcess(PChar(name),'',nil, nil,False, NORMAL_PRIORITY_CLASS,
nil, nil, StartUpInfo, ProcessInfo) then
begin { wait for window}
if WaitForInputIdle(ProcessInfo.hProcess,1000) <> 0 then
begin
Result:=false; //no reaction ??
Exit;
end;
end
else
begin
Result:=false; // Program not found
Exit;
end;

WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
Result:=true;
end;
{---------------------------------------------------------------------------}

For parameters try to replace the empty string in CreateProcess (see
also in the helpfile)

I hope that will help you! - Ronny

0 new messages