Created
June 12, 2017 16:53
-
-
Save k-takata/f2262db2b342a49a76a70669ce8fdd0d to your computer and use it in GitHub Desktop.
Check Win10 build number and detect if escape sequences can be used (without manifest)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
typedef BOOL (WINAPI *PfnRtlGetVersion)(LPOSVERSIONINFOW); | |
#define MAKE_VER(major, minor, build) \ | |
(((major) << 24) | ((minor) << 16) | (build)) | |
int main() | |
{ | |
OSVERSIONINFOW osver = {sizeof(OSVERSIONINFOW)}; | |
HMODULE hNtdll; | |
PfnRtlGetVersion pRtlGetVersion; | |
DWORD ver; | |
hNtdll = GetModuleHandle(TEXT("ntdll.dll")); | |
pRtlGetVersion = (PfnRtlGetVersion) GetProcAddress(hNtdll, "RtlGetVersion"); | |
pRtlGetVersion(&osver); | |
printf("%u.%u.%u\n", osver.dwMajorVersion, osver.dwMinorVersion, osver. dwBuildNumber); | |
ver = MAKE_VER(min(osver.dwMajorVersion, 255), | |
min(osver.dwMinorVersion, 255), | |
min(osver.dwBuildNumber, 32767)); | |
if (ver >= MAKE_VER(10, 0, 10586)) { | |
printf("ENABLE_VIRTUAL_TERMINAL_PROCESSING is supported.\n"); | |
if (ver >= MAKE_VER(10, 0, 15063)) { | |
printf("Extended colors are supported.\n"); | |
} else { | |
printf("Extended colors are not supported.\n"); | |
} | |
} else { | |
printf("ENABLE_VIRTUAL_TERMINAL_PROCESSING is not supported.\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment