You can use RtlGetVersion
But for Windows 11, it is atm identified by the Build Number (>= 22000)
HMODULE hDll = LoadLibrary(TEXT("Ntdll.dll"));
typedef NTSTATUS(CALLBACK* RTLGETVERSION) (PRTL_OSVERSIONINFOW lpVersionInformation);
RTLGETVERSION pRtlGetVersion;
pRtlGetVersion = (RTLGETVERSION)GetProcAddress(hDll, "RtlGetVersion");
if (pRtlGetVersion)
{
RTL_OSVERSIONINFOW ovi = { 0 };
ovi.dwOSVersionInfoSize = sizeof(ovi);
NTSTATUS ntStatus = pRtlGetVersion(&ovi);
if (ntStatus == 0)
{
WCHAR wsMessage[255] = L"";
wsprintf(wsMessage, L"RtlGetVersion :\r\nMajor Version : %d\r\nMinor Version : %d\r\nBuild Number : %d", ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber);
MessageBox(NULL, wsMessage, L"Information", MB_OK | MB_ICONINFORMATION);
}
}