I have the following batch script:
dir | myapp.exe
And the program has this source (more or less):
procedure TForm1.FormCreate(Sender: TObject);
var buff: String;
begin
Read(buff);
Memo1.Lines.Text:=buff;
end;
And the output in the memo is:
Volume in drive C has no label.
I tried:
- putting the read part into a loop with
eofas a condition - somehow causing an infinite loop - writing a loop to keep reading until
strlen(buff)is 0 - it exits the second time for some reason - reading stuff ever 0.5 seconds (I was thinking about asynchronous writes to stdin), this failed as well
By the way, running the program directly, without stdin data, causes an EInputOutput exception (I/O Error) code 6.