0

I must check if windows 10 is installed on machine, because my program supports only win10.

I tried this solution that I already found on stackoverflow.

    if (IsWindowsVersionOrGreater(10, 0, 0))
    {
        //nothing
    }
    else
    {
        MessageBox(NULL, "Your OS is not supported.", "Version Not Supported", MB_OK);
    }

It giving me Your OS is not supported but why? Did I understand something wrong? Is there any other solutions to do it?

Best regards.

Hitchance
  • 13
  • 4
  • 4
    Does your application have a manifest that explicitly specifies the app supports Win10? If not, then most versioning APIs, including the one you mention, will think an earlier OS version is being used. This behavior is documented on MSDN: [Targeting your application for Windows](https://learn.microsoft.com/en-us/windows/win32/sysinfo/targeting-your-application-at-windows-8-1). If you dont want your app running on a version earlier than Win10, a better solution is to set the minimum version in your app EXE's PE header so it won't even load on earlier versions. – Remy Lebeau Jun 27 '20 at 19:04

1 Answers1

1

Have you looked at GetVersionEx() function and OSVERSIONINFOEX structure?

Possible usage:

void print_os_info()
{
    OSVERSIONINFOEX info;
    ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
    info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

    GetVersionEx(&info);

    printf("Windows version: %u.%u\n", info.dwMajorVersion, info.dwMinorVersion);
}

this is the source of the answer: Get OSVersion in Windows using C++