[fpc-devel] Console IO revisited

Michael Van Canneyt michael at freepascal.org
Fri Dec 3 13:50:19 CET 2010

On Fri, 3 Dec 2010, Thaddy wrote:

> On 3-12-2010 13:22, Thaddy wrote:
> ---
> CreateFile;
> lpFileName
> Use the CONIN$ value to specify console input.
> Use the CONOUT$ value to specify console output.
> CONIN$ gets a handle to the console input buffer, even if the SetStdHandle function redirects the standard input handle. To get the standard
> input handle, use the GetStdHandlefunction.
> CONOUT$ gets a handle to the active screen buffer, even if SetStdHandleredirects the standard output handle. To get the standard output handle,
> use GetStdHandle.
> This behaveour is broken in FPC without intervention from the programmer in a very "unusual" way. (i.e. without hacks)

HOW is it broken ?

If you use the CreateFile() function from the windows unit, you are directly speaking 
to the operating system, FPC in no way interferes with that.

If you think that these functions or their description somehow apply or transfer to 
the standard Pascal Input, Output and stdErr text variables, then you are mistaken. 
The rules for these variables are governed by the pascal standard, not by the operating system.

If you want the functionality of the CreateFile() function, you must use Windows, 
and only windows, functions on the file handles thus obtained.


More information about the fpc-devel mailing list