Extended RGB colors using SetConsoleTextAttribute

Viewed 71

According to this link, using the string "\x1b[38;2;105;105;105m" can be used to change the text colors in the win32 color. It works fine, and this behavior works only on certain versions of Windows 10+.

Since this is using extended colors that take an RGB code rather than the predefined COLOR_XXX codes, I can't figure out how to implement this using SetConsoleTextAttribute. I need the same closest-matching color to be set, because this console app will also be used on pre-windows 10 systems.

For example, instead of using FOREGROUND_GREEN | FOREGROUND_RED | WHATEVER_COLOR is there a way to pass in the same RGB color codes?

0 Answers
Related