在Delphi控制台应用程序中的stdin / stdout上打开TStream

问题描述:

我正在尝试编写一个Delphi控制台应用程序,为其标准输入创建一个TStream,另一个TStream用于标准输出。

I'm trying to write a Delphi console application that creates a TStream for its standard input, and another TStream for its standard output.

(将会启动通过主机应用程序,其输入和输出重定向到管道,并将传递二进制数据到/从该主机应用程序,所以TStream将比ReadLn / WriteLn更适合任务。)

(It will be launched by a host app with its input and output redirected to pipes, and will be passing binary data to/from that host app, so TStream will be much better-suited to the task than ReadLn/WriteLn.)

如何在标准输入或标准输出上打开TStream?

How do I go about opening a TStream on standard input or standard output?

我的头顶:

  InputStream := THandleStream.Create(GetStdHandle(STD_INPUT_HANDLE));
  OutputStream := THandleStream.Create(GetStdHandle(STD_OUTPUT_HANDLE));

给你一个..