tzigan
asked on
start an ext. program
Using Delphi 5
I'll start an external program wich make the setup for another Prog. After this action I'll delete some files from the harddrive. So my Program must wait until end of the setupprogram. Also the paths must be relative like \\test\
Who have the tip?
I'll start an external program wich make the setup for another Prog. After this action I'll delete some files from the harddrive. So my Program must wait until end of the setupprogram. Also the paths must be relative like \\test\
Who have the tip?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great, I'll check it and get it to work. Thanks
try this procedure
function ExecAndWait(const FileName, Params: ShortString; const WinState: Word): boolean; export;
var
StartInfo: TStartupInfo;
ProcInfo: TProcessInformation;
CmdLine: ShortString;
begin
{ Put the name of file between quotes, due to spaces in names of files in system Win9x }
CmdLine := '"' + Filename + '" ' + Params;
FillChar(StartInfo, SizeOf(StartInfo), #0);
with StartInfo do
begin
cb := SizeOf(SUInfo);
dwFlags := STARTF_USESHOWWINDOW;
wShowWindow := WinState;
end;
Result := CreateProcess(nil, PChar( String( CmdLine ) ), nil, nil, false,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil,
PChar(ExtractFilePath(File
{ Wait the finish of program }
if Result then
begin
WaitForSingleObject(ProcIn
{ Free the Handles }
CloseHandle(ProcInfo.hProc
CloseHandle(ProcInfo.hThre
end;
end;
Mohammed