On 09/05/11 12:04, Anton Shepelev wrote:
Ludo Brands:

If you need these handles from the child process use:
InHnd:=GetStdHandle(STD_INPUT_HANDLE);
OutHnd:=GetStdHandle(STD_OUTPUT_HANDLE);
ErrHnd:=GetStdHandle(STD_ERROR_HANDLE);

Thank you, that's what I need.

By the way, it does work in a simple single-process applica-
tion:

     Program Test;
     uses Windows;

     var
        hIn:       LongWord;
        buf:       ShortString;
        bytesRead: LongWord;
     begin
        hIn := GetStdHandle(STD_INPUT_HANDLE);
        while(true) do begin
           ReadFile(hIn, buf[1], 5, bytesRead, nil);
           buf[0] := Chr(bytesRead);
           write(buf);
        end;
     end.

It is interesting to note that even this  code  reads  input
only after Enter is pressed.

Look at SetConsoleMode:

http://msdn.microsoft.com/en-us/library/ms686033%28v=VS.85%29.aspx

You should be able to read single characters if you disable the ENABLE_LINE_INPUT mode.

Henry
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to