I have a Startandwait function that creates a process and wait for the end. How do I create a progress bar to indicate the progress of the process?
function StartRAndWait (CommandLine : string) : Boolean;
var
Proc_info: TProcessInformation;
Startinfo: TStartupInfo;
ExitCode: longword;
CreateOK : Boolean;
begin
Result := False;
FillChar(proc_info, sizeof (TProcessInformation), #0);
FillChar(startinfo, sizeof (TStartupInfo), #0);
Startinfo.cb := sizeof (TStartupInfo);
Startinfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
Startinfo.wShowWindow := SW_HIDE;
CreateOK := CreateProcess(Nil, PChar('Program.exe ' + 'CMD BATCH ARQ.EXT SampleOutput.txt'), nil,
nil,False, CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS, nil,nil, StartInfo, proc_info);
if (CreateOK) then
begin
WaitForSingleObject (proc_info.hProcess, INFINITE);
GetExitCodeProcess(proc_info.hProcess, ExitCode);
Result := True
end;
CloseHandle(proc_info.hThread);
CloseHandle(proc_info.hProcess);
end;