Home

GetConsoleScreenBufferInfo

GetConsoleScreenBufferInfo is a function in the Win32 API that retrieves information about a specified console screen buffer. It fills a CONSOLE_SCREEN_BUFFER_INFO structure with current buffer and window settings, including buffer size, cursor position, text attributes, and window dimensions.

The function signature is BOOL GetConsoleScreenBufferInfo(HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo). The hConsoleOutput parameter is a handle to

The CONSOLE_SCREEN_BUFFER_INFO structure contains several fields: dwSize is a COORD describing the buffer size in character

Typical uses include querying the console environment to adapt text layout, determining if a resize is possible,

an
active
console
screen
buffer,
usually
obtained
from
GetStdHandle(STD_OUTPUT_HANDLE)
or
another
console
handle.
The
lpConsoleScreenBufferInfo
parameter
is
a
pointer
to
the
structure
that
receives
the
information.
The
function
returns
a
nonzero
value
on
success
and
zero
on
failure;
use
GetLastError
for
details.
cells;
dwCursorPosition
(COORD)
is
the
current
cursor
position;
wAttributes
(WORD)
holds
the
current
text
attributes
such
as
foreground
and
background
colors;
srWindow
(SMALL_RECT)
defines
the
current
window
dimensions
within
the
buffer;
dwMaximumWindowSize
(COORD)
is
the
maximum
allowed
window
size.
and
coordinating
output
with
the
visible
window.
The
information
can
be
used
in
tandem
with
SetConsoleWindowInfo,
SetConsoleScreenBufferSize,
and
related
APIs.