void printString(const wchar_t* cs) {
if (cs == NULL) {
return;
}
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), cs, wcslen(cs), 0, NULL);
}
void printErrorString(const wchar_t* cs) {
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY);
printString(cs);
SetConsoleTextAttribute(h,
FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
}
参考上面的代码;
也就是使用win32 API, SetConsoleTextAttribute 和 WriteConsoleW