roken: Windows version support helpers

Add helper functions for determining the version of Windows upon which we are
running.
This commit is contained in:
Luke Howard
2019-11-13 15:56:22 +11:00
committed by Jeffrey Altman
parent 61452235ad
commit 3daef8a5fd
3 changed files with 141 additions and 27 deletions

View File

@@ -36,33 +36,7 @@
#ifdef HAVE_WIN32_RAND_S
static int hasRand_s = 1;
// The Following is BackPorted from VersionHelpers.h in the 10.0.15063.0 SDK
static FORCEINLINE BOOL
IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
{
OSVERSIONINFOEXW osvi ={ sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0 };
DWORDLONG const dwlConditionMask = VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
osvi.dwMajorVersion = wMajorVersion;
osvi.dwMinorVersion = wMinorVersion;
osvi.wServicePackMajor = wServicePackMajor;
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
}
static FORCEINLINE BOOL
IsWindowsXPOrGreater()
{
// Assume that _WIN32_WINNT_WINXP (0x0501) not available so use contants.
return IsWindowsVersionOrGreater(5, 1, 0);
}
#include "versionsupport.h"
#endif
void ROKEN_LIB_FUNCTION