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.
[Visual Basic]Friend Shared Function SetConsoleTextAttribute( _
ByVal hConsoleOutput As Integer, _
ByVal wAttributes As Integer _
) As Integer
[C#]
internal static int SetConsoleTextAttribute(
int hConsoleOutput,
int wAttributes
);
Parameters
- hConsoleOutput
- Handle to a console screen buffer. The handle must have GENERIC_READ access.
- wAttributes
- Specifies the foreground and background color attributes. Any combination of the following values can be specified: FOREGROUND_BLUE, FOREGROUND_GREEN, FOREGROUND_RED, FOREGROUND_INTENSITY, BACKGROUND_BLUE, BACKGROUND_GREEN, BACKGROUND_RED, and BACKGROUND_INTENSITY.
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.
See Also
ConsoleAttributes Class | ConsoleAttributes Members | Org.Mentalis.Utilities.ConsoleAttributes Namespace