ReadConsole

  BOOL ReadConsole(hConsoleInput, lpvBuffer, cchToRead, lpcchRead, lpvReserved)    
  HANDLE hConsoleInput; /* identifies console input buffer */
  LPVOID lpvBuffer; /* points to buffer to receive data */
  DWORD cchToRead; /* number of characters to read */
  LPDWORD lpcchRead; /* number of characters actually read */
  LPVOID lpvReserved; /* reserved */

The ReadConsole function reads character input from the console input buffer and removes it from the buffer.

Parameters

hConsoleInput

Identifies the console input buffer to read. The handle must have been created with GENERIC_READ access.

lpvBuffer

Points to a buffer to receive the data read from the console input buffer.

cchToRead

Specifies the number of characters to read. Since the function can read either Unicode or ASCII characters, the size of the lpvBuffer buffer should be cchToRead * sizeof(TCHAR).

lpcchRead

Points to a variable that will be set to the number of characters actually read.

lpvReserved

Reserved for future use.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

Comments

The ReadConsole function may be used as either a wide-character function (where Unicode characters will be returned) or an ANSI function (where the characters returned will be from the Windows 3.x character set installed).

ReadConsole reads keyboard input from a console input buffer. It behaves like ReadFile reading console input except that it can be used to read in either wide-character or ANSI mode. Applications that want to be compatible with both modes should use ReadConsole rather than ReadFile.

All of the input modes that affect the behavior of ReadFile have the same effect on ReadConsole.

If the input buffer contains input events other keyboard events (such as mouse events or window resize events), they are discarded. Such events can only be read using ReadConsoleInput.

See Also

WriteConsole, ReadConsoleInput, GetConsoleMode, SetConsoleMode