Capture text from dos window lazarus / 8-Other ---------------------------------------------------------------------- PaulAtreides62 · 2009-03-16 19:19 I want to capture the output from a cosole program for windows, with an application under win32. I found an intresting code , for delphi, at http://delphi.about.com/cs/adptips2001/a/bltip0201_2.htm and i try the code with delphi, and then with lazarus. I create an application with a memo component, as in the code; It is all ok if the output of the console program is less then approximately 4000 bytes, otherwise the application i create with the memo jams. Why?? thanks to everybody!! ---------------------------------------------------------------------- Marc · 2009-03-17 10:01 are you repeately reading the stdout pipe ? on windows a pipe can contain max 4k and then it halts, unless you read from it. ---------------------------------------------------------------------- PaulAtreides62 · 2009-03-17 12:23 Hi Marc. Is it possible to modify in windows the dimension of the pipe? The problem is, i think, that the instruction Code: [Select]  if CreateProcess(nil,            PChar(DosApp),            @Security,            @Security,            true,            NORMAL_PRIORITY_CLASS,            nil,            nil,            start,            ProcessInfo) call the console program, but if it writes in the pipe more then 4k bytes, the Createprocess jams; is it correct? Is there a way to read from the pipe while the createprocess is also running? thanks still ---------------------------------------------------------------------- Marc · 2009-03-17 13:12 iirc you cannot increase it (and what if you can, you still need to read) CreateProcess doesn't block, so after creation repeat reading the bytes in the first repeat loop. The example you gave is wrong, this will block on delphi (or any other language) too ---------------------------------------------------------------------- Bart · 2009-03-17 14:16 From one of my units (it's linux though) using TProcess Code: [Select]  begin     Proc := tprocess.Create(nil);     SL := TStringList.Create;     try     Proc.CommandLine := 'ps -ux';     Proc.Options := [poUsePipes, poWaitonexit];     try       Proc.Execute;       SL.LoadFromStream(Proc.OutPut);  The output of ps -us now appears in my stringlist. Bart ---------------------------------------------------------------------- PaulAtreides62 · 2009-03-17 17:58 Hi Bart. I have used your code in this way: I have add a Tprocess (process1) and a Tmemo (memo1) component. the result is ( with some addition ): Code: [Select]procedure TForm1.Button1Click(Sender: TObject); begin     try     Process1.CommandLine := 'c:\prova1.exe';     Process1.Options := [poUsePipes, poWaitonexit];     Process1.ShowWindow:=swoHIDE;       try       Process1.Execute;       Memo1.Lines.LoadFromStream(Process1.OutPut);       except       label1.Caption :='Errore di caricamento del programma esterno';       end;    except    label2.Caption :='Errore di gestione delle opzioni';    end; end;  If the output of the prova1.exe is small ( less then 4k i suppose ) all it's ok, but if the output is grater, the application jams; where I am wrong?? thanks to everybody ---------------------------------------------------------------------- Marc · 2009-03-17 22:54 see wiki ---------------------------------------------------------------------- PaulAtreides62 · 2009-03-18 14:23 Hi to everybody. The wiki is clear and the problem is solved. thanks, Marc.