Platform SDK: Files and I/O |
The SetConsoleTextAttribute function sets the foreground (text) and background color attributes of characters written to the screen buffer by the WriteFile or WriteConsole function, or echoed by the ReadFile or ReadConsole function. This function affects only text written after the function call.
BOOL SetConsoleTextAttribute( HANDLE hConsoleOutput, // handle to screen buffer WORD wAttributes // text and background colors );
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
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.
To determine the current color attributes of a screen buffer, call the GetConsoleScreenBufferInfo function.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Wincon.h; include Windows.h.
Library: Use Kernel32.lib.
Consoles and Character-Mode Support Overview, Console Functions, GetConsoleScreenBufferInfo, ReadConsole, ReadFile, WriteConsole, WriteFile