Reputation: 379
I wonder if there's any API or way to detect if an application is running on Windows 11.
While searching I found these apis but it lack a specific for Windows 11, there's an IsWindowsXXOrGreater
but I'm not sure which version to check and how to use it.
I also found some similar questions on StackOverflow but referring to Windows 10, I tried some of the answers but I still couldn't get a 'conclusive' way to check for it.
This show '10' when tested on Windows 11:
NTSTATUS(WINAPI *RtlGetVersion)(LPOSVERSIONINFOEXW);
OSVERSIONINFOEXW osInfo;
*(FARPROC*)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
if (NULL != RtlGetVersion)
{
osInfo.dwOSVersionInfoSize = sizeof(osInfo);
RtlGetVersion(&osInfo);
qDebug() << "version: " << (double)osInfo.dwMajorVersion;
MessageBoxA(NULL, std::to_string((double)osInfo.dwMajorVersion).c_str(), NULL, 0);
}
Upvotes: 1
Views: 3183
Reputation: 595422
Windows 11 is an extension of Windows 10, so it does not increment the major/minor version numbers reported by RtlGetVersion()
and other similar APIs, and does not add a new <supportedOS>
guid in application manifests.
Windows 11 is still reported as v10.0, as shown in the OSVERSIONINFOEXW
documentation:
The following table summarizes the version information that is returned by supported versions of Windows. Use the information in the "Other" column or build number to distinguish between operating systems with identical version numbers.
Operating system Version number dwMajorVersion dwMinorVersion Other Windows 11 10.0 10 0 wProductType == VER_NT_WORKSTATION Windows Server 2022 10.0 10 0 wProductType != VER_NT_WORKSTATION Windows Server 2019 10.0 10 0 wProductType != VER_NT_WORKSTATION Windows 10 (all releases) 10.0 10 0 wProductType == VER_NT_WORKSTATION
So, you need to use the build number to differentiate between Windows 10 and 11. Windows 11 is v10.0 build 21996 and higher.
Upvotes: 3