开发者

How write a file to STDIN Stream using DELPHI?

I need to write a FILE to STDIN. This FILE going to be accessed by another EXE that goig to write the STDIN stream in a micro开发者_如何学Ccontroller.

Could you give me a help how to write the file to STDIN using Delphi 2010?

Thanks very much!


I think you mean STDOUT.

Is the Allen Bauer's answer is what are you looking for?


It looks like you're trying to write to some sort of output that the other EXE will see as its STDIN stream. In that case, Allen Bauer's answer mentioned by Serg is close, but it's not going to be enough for you.

There's some sample code on MSDN that explains how to do this, but it's all in C and hard to read. The important part is this:

Call CreatePipe, which is declared in Windows.pas. The first two parameters are var parameters to THandle variables that CreatePipe will fill with the read handle and the write handle of the pipe. Then you need to set up a TStartupInfo record. Assign the read handle to your pipe to the hStdInput field of the TStartupInfo.

You pass the TStartupInfo to CreateProcess to spawn the second EXE, and then you can create a THandleStream like in Allen's example, passing it the write handle of the pipe. That way, anything you write into the stream gets piped to the read end to be read by the other EXE.

Hope that helps...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜