简体   繁体   中英

Check if windows10 is installed C++

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.

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++

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM