I am trying to write a C++ program that identifies current Windows version. I saw dozens of such questions and answers but none of them worked for me.
I am running Windows 10 Home edition.
I am using Visual Studio 2015.
First options that I have tried:
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
cout << osvi.dwMajorVersion << endl;
cout << osvi.dwMinorVersion << endl;
This prints 6 and 2 which according to MSDN corresponds to Windows 8.
Second options that I have tried:
#include <VersionHelpers.h>
if (IsWindowsVistaOrGreater())
printf("VistaOrGreater\n");
if (IsWindows7OrGreater())
printf("Windows7OrGreater\n");
if (IsWindows8OrGreater())
printf("Windows8OrGreater\n");
if (IsWindows8Point1OrGreater())
printf("Windows8Point1OrGreater\n");
if (IsWindows10OrGreater())
printf("Windows10OrGreater\n");
In this way, IsWindows10OrGreater() is not defined in my system and gives compile error.
Any help with this?
In Windows 8.1 and Windows 10, the GetVersion and GetVersionEx functions have been deprecated. Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2)
see Targeting your application for Windows for more info.