Limited access to the input and output buffers of a console is available through the functions for File I/O. The application can use ReadFile with a handle to StdIn to get keyboard input; and it can use WriteFile with a handle to a screen buffer to write from a character buffer to the specified screen buffer at its current cursor location. Other functions that support the use of console handles include DuplicateHandle and CloseHandle which can be used with either input or output handles. CreateFile can be used to open a handle to console input, “CONIN$”. CreateFile can also be used to return a handle to the active screen buffer, “CONOUT$”, if the process has an open handle to it (with inheritance or duplication).
The form of input and output for applications using the File functions is affected by console modes which may be enabled or disabled. The following modes may be enabled for the input handle: line input, processed input, echo input. In line input mode, applications using ReadFile will not get console input until a carriage return has been input. In processed input mode, control characters are handled by ReadFile . This means that editing keys such as backspace and tab are handled appropriately, and Ctrl-C is passed on to the handler routines. In echo input mode, characters read by ReadFile are echoed to console output. Echoing only occurs if line input is also enabled. The following modes may be enabled for the output handle: wrap at EOL, processed output. The File functions can send output to the screen buffer by writing using WriteFile or when using ReadFile if echoing is enabled. Wrap at EOL output mode determines whether long output lines will wrap to the beginning of the next line or be discarded beyond the end of the line. Processed output mode enables the output characters to be parsed for ASCII control sequences and the correct action performed.
Applications using ReadFile and WriteFile to write output to a console screen buffer can specify the color attribute with which subsequent characters will be written.