im modifying my GUI app that calls a CLI app to redirect its standard output
to the TMemo of the GUI app in real time, but its just doing nothing, their is no
errors too, the documentation of the console app im using stated this
If you want to monitor HandBrake's process, you should monitor the standard pipes.
* Standard Output: Contains encode progress information.
* Standard Error: Contains all the logging data.
source: https://trac.handbrake.fr/wiki/CLIGuide
i want the encode progress info be shown on TMemo in real time so that it will
serve as some sort of progress bar or progress indicator, that is why
im piping the standard output but so far i failed, here are parts of the code in question
var
S: TStringList;
M: TMemoryStream;
n: longInt;
BytesRead: longInt;
const
READ_BYTES = 2048;
//////////////////////////////////
//Hbk is the TProcess
Hbk.CommandLine := lstOut.Items[i];
Hbk.Options := [poUsePipes];
Hbk.Execute;
S := TStringList.Create;
M := TMemoryStream.Create;
while Hbk.Running do
begin
M.SetSize(BytesRead + READ_BYTES);
n := Hbk.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
if n > 0 then
begin
Inc(BytesRead,n);
end;
end;
repeat
M.SetSize(BytesRead + READ_BYTES);
n := Hbk.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
if n > 0 then
begin
Inc(BytesRead,n);
end;
until n <= 0;
M.SetSize(BytesRead);
S.LoadFromStream(M);
//mmoOut is the TMemo
mmoOut.Lines := S;
//mmoOut.Lines.LoadFromStream(M);
M.Free;
S.Free;
on the other question thread i made i got a reply that says this
The article about capturing standard output and sending data to it's standard input worked fine for me on XP (http://wiki.lazarus.freepascal.org/Executing_External_Programs#How_to_redirect_output_with_TProcess).
I used threading though to make it run in parallel with the main thread.
and im new to this standard streams, but did he mean the data i will read on standard output of HandbrakeCLI.exe will have to be send to the standard input of HandbrakeCLI.exe? then if so how can i get the data on standard input and show it on TMemo of my GUI app in real-time?