0

I wrote some code to get the Windows version, utilizing the GetVersionEx function. Here it is:

#include <windows.h>
#include <stdio.h>

int main() {
    OSVERSIONINFO ver;
    ZeroMemory(&ver, sizeof(OSVERSIONINFO));
    ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    GetVersionEx(&ver);
    printf("Version is %i.%i build %i", ver.dwMajorVersion, 
    ver.dwMinorVersion, ver.dwBuildNumber); 
}

When run on my Windows 10 Pro build 15063 system, it reports that the program is run on a Windows 8.1 build 9200 system.

How can I solve this?

adrian
  • 1,439
  • 1
  • 15
  • 23
  • 1
    Is it by any chance running in compatibility mode? – Havenard Sep 24 '17 at 21:56
  • Yes, I do think so; by changing it to be compatible with Vista via properties it reports so. – adrian Sep 24 '17 at 21:58
  • 1
    There are a lot of existing questions about this. But the correct resolution depends on *why* you're trying to get the version number, which you haven't explained. – Harry Johnston Sep 25 '17 at 01:07
  • 1
    @RbMm, if too many people start using `RtlGetVersion` then it *will* be hobbled in some future release of Windows, for the same reason `GetVersionEx` was hobbled in Windows 8. – Harry Johnston Sep 25 '17 at 01:09

0 Answers0