I know how to set them (SetConsoleTextAttribute) but there isn’t a GetConsoleTextAttribute to retrieve this information. On a unaffected console it should be int 7.
The problem is that when exiting from a program that sets the text color it stays the same for the time given window runs, and I cannot assume that user hasn’t set the colors to his custom liking.
A quick grep of
wincon.hshows thatCONSOLE_SCREEN_BUFFER_INFOhas awAttributesmember which is documented as “The attributes of the characters written to a screen buffer by the WriteFile and WriteConsole functions, or echoed to a screen buffer by the ReadFile and ReadConsole functions.” This matches the description ofSetConsoleTextAttribute: “Sets the attributes of characters written to the console screen buffer by the WriteFile or WriteConsole function, or echoed by the ReadFile or ReadConsole function.” The structure is returned byGetConsoleScreenBufferInfo.