PeekConsoleInput

  BOOL PeekConsoleInput(hConsoleInput, pirBuffer, cInRecords, lpcRead)    
  HANDLE hConsoleInput; /* identifies console input buffer */
  PINPUT_RECORD pirBuffer; /* address of the buffer for peek data */
  DWORD cInRecords; /* number of records to read */
  LPDWORD lpcRead; /* receives number of records read */

The PeekConsoleInput function reads data from the specified console input buffer without removing it from the buffer.

Parameters

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.

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

If the number of records requested exceeds the number of records available in the buffer, the number available are read. If no data is available, the function returns immediately.

The PeekConsoleInput function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

See Also

ReadConsoleInput, WriteConsoleInput