BOOL ReadConsoleInput(hConsoleInput, pirBuffer, cInRecords, lpcRead) | |||||
HANDLE hConsoleInput; | /* identifies console input buffer | */ | |||
PINPUT_RECORD pirBuffer; | /* address of the buffer for read data | */ | |||
DWORD cInRecords; | /* number of records to read | */ | |||
LPDWORD lpcRead; | /* receives number of records read | */ |
The ReadConsoleInput function reads data from the console input buffer and removes it from the buffer.
hConsoleInput
Identifies the console input buffer to read. The handle must have been created with GENERIC_READ access.
pirBuffer
Points to an INPUT_RECORD buffer to receive the console input buffer data.
The INPUT_RECORD data structure has the following format:
typedef struct _INPUT_RECORD { /* ir */
WORD EventType;
union {
KEY_EVENT_RECORD KeyEvent;
MOUSE_EVENT_RECORD MouseEvent;
WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
MENU_EVENT_RECORD MenuEvent;
FOCUS_EVENT_RECORD FocusEvent;
} Event;
} INPUT_RECORD;
cInRecords
Specifies the length of pirBuffer (in input records).
lpcRead
Points to a variable to receive the number of input records read.
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.
If the number of records requested exceeds the number of records available in the buffer, the number available are read. The function does not return until at least one event has been read into the caller's buffer. GetNumberOfConsoleInputEvents can be used to determine the number of events in the console's input buffer. WaitForSingleObject or WaitForMultipleObjects can be used to wait for a handle to console input to be Signalled. This occurs when the input buffer is not empty.
The ReadConsoleInput function may be used as either a wide-character function (where the characters returned in a keyboard INPUT_RECORD will be Unicode) or an ANSI function (where the characters returned will be from the Windows 3.x character set installed).
PeekConsoleInput, WriteConsoleInput, ReadConsole, ReadFile