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);
}