ReadConsoleOutputAttribute

  BOOL ReadConsoleOutputAttribute(hConsoleOutput, lpwAttribute, cReadCells, coordReadCoord, lpcNumberRead)    
  HANDLE hConsoleOutput; /* identifies console screen buffer */
  LPWORD lpwAttribute; /* points to buffer to receive attributes */
  DWORD cReadCells; /* number of character cells to read from */
  COORD coordReadCoord; /* coordinates of first cell to read from */
  LPDWORD lpcNumberRead; /* actual number or cells read from */

The ReadConsoleOutputAttribute function reads a string of foreground and background color attributes from a console screen buffer beginning at the specified location.

Parameters

hConsoleOutput

Specifies an open handle to a console screen buffer from which to read. The handle must have been created with GENERIC_READ access.

lpwAttribute

Points to a buffer to receive the attribute string read from the screen buffer.

cReadCells

Specifies the number of screen buffer character cells from which to read. The size of the lpwAttribute buffer should be cReadCells * sizeof(WORD).

coordReadCoord

Specifies the column and row coordinates of the first cell in the screen buffer from which to read.

lpcNumberRead

Points to a DWORD that the function will set on exit to the number of attributes read.

Return Value

If the function is successful, the return value is TRUE. Otherwise, it is FALSE. Extended error information can be obtained by calling the GetLastError function.

Comments

This function reads an attribute string from the screen buffer. If the number of attributes to read extends beyond the end of the specified row in the screen buffer, attributes are read from the next row. If the number of attributes to read extends beyond the end of the screen buffer, the attributes up to the end of the screen buffer are read.

Each attribute specifies the foreground and background colors in which that character cell will be drawn. The attribute values will be some combination of the color constants, such as FOREGROUND_RED or BACKGROUND_BLUE, that are defined in wincon.h.

See Also

ReadConsoleOutput, ReadConsoleOutputCharacter, WriteConsoleOutput, WriteConsoleOutputAttribute, WriteConsoleOutputCharacter