Skip to content

Instantly share code, notes, and snippets.

@jonwis
Last active July 9, 2022 02:15
Show Gist options
  • Save jonwis/a159bd8c6119c7e20b5a2cf0f7fe2253 to your computer and use it in GitHub Desktop.
Save jonwis/a159bd8c6119c7e20b5a2cf0f7fe2253 to your computer and use it in GitHub Desktop.
Version query for Windows 10 builds
#include <versionhelpers.h>
bool IsWindows10BuildOrGreater(uint16_t buildNumber)
{
OSVERSIONINFOEXW osvi = { sizeof(osvi) };
const auto conditionMask = VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL),
VER_BUILDNUMBER, VER_GREATER_EQUAL);
osvi.dwMajorVersion = HIBYTE(_WIN32_WINNT_WINTHRESHOLD);
osvi.dwMinorVersion = LOBYTE(_WIN32_WINNT_WINTHRESHOLD);
osvi.dwBuildNumber = buildNumber;
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_BUILDNUMBER, conditionMask) != FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment