Skip to content

Latest commit

 

History

History
161 lines (121 loc) · 5.1 KB

readconsoleinputex.md

File metadata and controls

161 lines (121 loc) · 5.1 KB
title description author ms.author ms.topic keywords f1_keywords MS-HAID MSHAttr ms.assetid topic_type api_name api_location api_type
ReadConsoleInputEx function
Reads data from a console input buffer with a specified set of flags and removes it from the buffer.
DHowett
duhowett
article
console, character mode applications, command line applications, terminal applications, console api
consoleapi/ReadConsoleInputEx
wincon/ReadConsoleInputEx
ReadConsoleInputEx
consoleapi/ReadConsoleInputExA
wincon/ReadConsoleInputExA
ReadConsoleInputExA
consoleapi/ReadConsoleInputExW
wincon/ReadConsoleInputExW
ReadConsoleInputExW
\_win32\_readconsoleinputex
base.readconsoleinputex
consoles.readconsoleinputex
PreferredSiteName:MSDN
PreferredLib:/library/windows/desktop
5a9f7b18-cdea-4041-a377-5532d30e0105
apiref
ReadConsoleInputEx
ReadConsoleInputExA
ReadConsoleInputExW
Kernel32.dll
API-MS-Win-Core-Console-l1-1-0.dll
KernelBase.dll
API-MS-Win-DownLevel-Kernel32-l1-1-0.dll
MinKernelBase.dll
DllExport

ReadConsoleInputEx function

Reads data from a console input buffer and removes it from the buffer, with configurable behavior.

Note This function has no associated import library. This function is available as the resources named ReadConsoleInputExA and ReadConsoleInputExW in Kernel32.dll. You must use the LoadLibrary and GetProcAddress functions to dynamically link to Kernel32.dll.

Syntax

BOOL WINAPI ReadConsoleInputEx(
  _In_  HANDLE        hConsoleInput,
  _Out_ PINPUT_RECORD lpBuffer,
  _In_  DWORD         nLength,
  _Out_ LPDWORD       lpNumberOfEventsRead,
  _In_  USHORT        wFlags
);

Parameters

hConsoleInput [in]
A handle to the console input buffer. The handle must have the GENERIC_READ access right. For more information, see Console Buffer Security and Access Rights.

lpBuffer [out]
A pointer to an array of INPUT_RECORD structures that receives the input buffer data.

nLength [in]
The size of the array pointed to by the lpBuffer parameter, in array elements.

lpNumberOfEventsRead [out]
A pointer to a variable that receives the number of input records read.

wFlags [in]

A set of flags (ORed together) that specify the console's reading behavior.

Value Meaning
CONSOLE_READ_NOREMOVE 0x0001 Leave the events in the input buffer (as in PeekConsoleInput)
CONSOLE_READ_NOWAIT 0x0002 Return immediately, even if there are no events in the input buffer.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

This function is a configurable version of ReadConsoleInput. See the remarks for ReadConsoleInput for additional operational details.

Calling ReadConsoleInputEx with the flags CONSOLE_READ_NOREMOVE | CONSOLE_READ_NOWAIT is equivalent to calling PeekConsoleInput.

This function does not exist in the Windows Console headers. To gain access to it from a C or C++ application, include the following declarations and dynamically link kernel32.dll as noted above.

#ifndef CONSOLE_READ_NOREMOVE
#define CONSOLE_READ_NOREMOVE   0x0001
#endif

#ifndef CONSOLE_READ_NOWAIT
#define CONSOLE_READ_NOWAIT     0x0002
#endif

BOOL
WINAPI
ReadConsoleInputExA(
    _In_ HANDLE hConsoleInput,
    _Out_writes_(nLength) PINPUT_RECORD lpBuffer,
    _In_ DWORD nLength,
    _Out_ LPDWORD lpNumberOfEventsRead,
    _In_ USHORT wFlags);

BOOL
WINAPI
ReadConsoleInputExW(
    _In_ HANDLE hConsoleInput,
    _Out_writes_(nLength) PINPUT_RECORD lpBuffer,
    _In_ DWORD nLength,
    _Out_ LPDWORD lpNumberOfEventsRead,
    _In_ USHORT wFlags);

Requirements

   
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Header none, see remarks
Library none, see remarks
DLL Kernel32.dll
Unicode and ANSI names ReadConsoleInputExW (Unicode) and ReadConsoleInputExA (ANSI)

See also

Console Functions

FlushConsoleInputBuffer

GetNumberOfConsoleInputEvents

INPUT_RECORD

Low-Level Console Input Functions

ReadConsoleInput

PeekConsoleInput

ReadConsole

ReadFile

SetConsoleCP

SetConsoleOutputCP

WriteConsoleInput