http://msdn.microsoft.com/en-us/library/ms724451%28v=vs.85%29.aspx
That doesn't work reliably anymore since Windows 8.1 onwards. That same page explains why:
With the release of Windows 8.1, the behavior of the GetVersionEx API has changed in the value it will return for the operating system version. The value returned by the GetVersionEx function now depends on how the application is manifested.
Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). Once an application is manifested for a given operating system version, GetVersionEx will always return the version that the application is manifested for in future releases.
If you don't manifest your app correctly, GetVersionEx() won't report the actual Windows version:
- If you don't manifest at all, it will report 8.0 when running on 8.1+.
- If you manifest only up to 8.1, it will report 8.1 when running on 10.0+.
- If you manifest only up to 10.0, it will report 10.0 when running on 10.1+.
And so on...
Every time a new version of Windows is released that requires a new manifest entry, you have to retest your app on that version and update your manifest accordingly so that Windows knows the app is compatible with that new version, otherwise Windows will dummy itself down for the version(s) that your app actually claims to support.
A more reliable way (for now) is to use
RtlGetVersion() instead, as it is not subject to manifestation (yet?).
I use the recommendation from here...
https://wiki.freepascal.org/WindowsVersion
Worked for me.
That approach (using
GetVersion()) is subject to the same manifest issue as GetVersionEx() on Windows 8.1 onward.