16DWORD INVALID_MODE = 0xffffffff;
17DWORD dwOriginalOutMode = 0xffffffff;
27 if (dwOriginalOutMode != INVALID_MODE && hOut != INVALID_HANDLE_VALUE)
29 SetConsoleMode(hOut, dwOriginalOutMode);
44 hOut = GetStdHandle(STD_OUTPUT_HANDLE);
45 if (hOut != INVALID_HANDLE_VALUE)
47 if (!GetConsoleMode(hOut, &dwOriginalOutMode))
49 dwOriginalOutMode = INVALID_MODE;
50 DWORD lastError = GetLastError();
51 printf(
"Failed to get the Console output's original mode (code = 0x%x).\n", lastError);
55 DWORD dwRequestedOutModes = ENABLE_VIRTUAL_TERMINAL_PROCESSING;
56 DWORD dwOutMode = dwOriginalOutMode | dwRequestedOutModes;
57 if (!SetConsoleMode(hOut, dwOutMode))
59 DWORD lastError = GetLastError();
60 printf(
"Failed to enable the Console output's virtual terminal mode (code = 0x%x).\n", lastError);
66 printf(
"Failed to get the Console's output handle.\n");
void enableVTMode(void)
Enables the virtual terminal processing mode on the current Windows Console. When the program ends,...
static void _restoreVTMode(void)
Called by atexit() on program termination to restore the video mode.
Declaration of the enableVTMode() function for configuring standard input to support the virtual term...
int INVALID_HANDLE_VALUE
Windows indicator of an invalid handle.