GUI applications do not have automatically assigned stdin, stdout, or stderr. You can do something like:
procedure TForm1.FormCreate(Sender: TObject); var Buffer: array[0..1000] of Byte; StdIn: TStream; Count: Integer; begin StdIn := THandleStream.Create(GetStdHandle(STD_INPUT_HANDLE)); Count := StdIn.Read(Buffer, 1000); StdIn.Free; ShowMessageFmt('%d', [Count]); end;
If you do
dir *.pas | myapp.exe
You will see a message with a number> 0, and if you do:
myapp.exe
You will see message number 0. In both cases, a form will be displayed.
Rudy velthuis
source share