HOWTO detect WIN11 using Windows API

The main problem here is that Windows 11 is a Windows 10++, and there is no function like IsWindows10OrGreater().

This forced us to write down our own IsWindows11OrGreater().

I want to write a function similar to the existing IsWindows*() using VerifyVersionInfo().

Here is the working body of such a function:

BOOL IsWindows11OrGreater()
{
    OSVERSIONINFOEX vi;
    ULONGLONG conditions;

    memset (&vi, 0, sizeof(vi));
    vi.dwOSVersionInfoSize = sizeof(vi);
    vi.dwMajorVersion = 10;
    vi.dwMinorVersion = 0;
    vi.dwBuildNumber = 21996;
    conditions = VerSetConditionMask (0,
            VER_MAJORVERSION, VER_GREATER_EQUAL);
    conditions = VerSetConditionMask (conditions,
            VER_MINORVERSION, VER_GREATER_EQUAL);
    conditions = VerSetConditionMask (conditions,
            VER_BUILDNUMBER, VER_GREATER_EQUAL);

    return VerifyVersionInfo (&vi,
            VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER,
            conditions) != FALSE;
}

Good Luck