views:

100

answers:

2

Hi,

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 microcontroller.

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

Thanks very much!

Abraão

+3  A: 

I think you mean STDOUT.

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

Serg
+2  A: 

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...

Mason Wheeler
If the question is about pipes, look at the answers on SO question http://stackoverflow.com/questions/512366/how-do-i-send-a-string-from-one-instance-of-my-delphi-program-to-another
Serg