SetConsoleMode(handle, ENABLE_VIRTUAL_TERMINAL_PROCESSING)
,会发生什么情况?ENABLE_VIRTUAL_TERMINAL_PROCESSING
的Windows与支持的模式,但SetConsoleMode()
因其他原因而失败?答案 0 :(得分:0)
回答我自己的问题:
由于规范没有提供具体答案,我们不得不使用Windows版本做出决定:
/**
* @param majorVersion a major version number
* @param minorVersion a minor version number
* @param buildVersion a build version number
* @return true if the Windows version is greater than or equal to the specified number
*/
bool isWindowsVersionOrGreater(WORD majorVersion, WORD minorVersion, WORD buildVersion)
{
// See http://stackoverflow.com/a/36545162/14731 and https://github.com/DarthTon/Blackbone/blob/master/contrib/VersionHelpers.h#L78
RTL_OSVERSIONINFOW verInfo = { 0 };
verInfo.dwOSVersionInfoSize = sizeof(verInfo);
static auto RtlGetVersion = (RtlGetVersionPtr) GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetVersion");
if (RtlGetVersion != 0 && RtlGetVersion(&verInfo) == 0)
{
if (verInfo.dwMajorVersion > majorVersion)
return true;
else if (verInfo.dwMajorVersion < majorVersion)
return false;
if (verInfo.dwMinorVersion > minorVersion)
return true;
else if (verInfo.dwMinorVersion < minorVersion)
return false;
if (verInfo.dwBuildNumber >= buildVersion)
return true;
}
return false;
}
如果Windows版本等于或大于10.0.14393
,则支持ENABLE_VIRTUAL_TERMINAL_PROCESSING
。