Do not call SetConsoleMode if the mode is already set

This commit is contained in:
anzz1 2023-03-20 02:02:29 +02:00 committed by GitHub
parent 0fed2ab999
commit b37e0950db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -944,7 +944,7 @@ int main(int argc, char ** argv) {
// Enable ANSI colors on Windows 10+
unsigned long dwMode = 0;
void* hConOut = GetStdHandle((unsigned long)-11); // STD_OUTPUT_HANDLE (-11)
if (hConOut && hConOut != (void*)-1 && GetConsoleMode(hConOut, &dwMode))
if (hConOut && hConOut != (void*)-1 && GetConsoleMode(hConOut, &dwMode) && !(dwMode & 0x4))
SetConsoleMode(hConOut, dwMode | 0x4); // ENABLE_VIRTUAL_TERMINAL_PROCESSING (0x4)
#endif
printf(ANSI_COLOR_YELLOW);