Skip to content

Instantly share code, notes, and snippets.

@sthalik
Last active November 11, 2022 11:54
Show Gist options
  • Save sthalik/17613fc4eefcae39d4e871d2f2fb7ecd to your computer and use it in GitHub Desktop.
Save sthalik/17613fc4eefcae39d4e871d2f2fb7ecd to your computer and use it in GitHub Desktop.
#ifdef _WIN32
#include <windows.h>
#ifdef _MSC_VER
#pragma comment(lib, "ntdll.lib")
#endif
extern "C" __declspec(dllimport) long WINAPI RtlGetVersion (PRTL_OSVERSIONINFOEXW);
static bool check_windows_build_number(unsigned major, unsigned minor, unsigned build)
{
if (RTL_OSVERSIONINFOEXW rovi = {.dwOSVersionInfoSize = sizeof(rovi)}; !RtlGetVersion(&rovi))
return rovi.dwMajorVersion > major ||
rovi.dwMajorVersion == major && rovi.dwMinorVersion > minor ||
rovi.dwMajorVersion == major && rovi.dwMinorVersion == minor && rovi.dwBuildNumber >= build;
else
return false;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment