-1

According to MSDN, GetVersionEx (the de facto way of getting the current windows version) has become deprecated as of Windows 8.1. Apparently it returns wrong values (corresponding to Windows 8) if called on a windows 8.1 or 10 machine. However, it can be made to return correctly if the application's manifest is modified correspondingly. But I'm not sure this is such a good solution since

GetVersionEx may be altered or unavailable for releases after Windows 8.1

I was thinking of simply reading the information I need from this registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion .

Is there any reason I should avoid doing this, given the current situation (API deprecation) ?

conectionist
  • 2,694
  • 6
  • 28
  • 50
  • possible duplicate of [How to get the OS version in Win8.1 as GetVersion/GetVersionEx are deprecated?](http://stackoverflow.com/questions/27246562/how-to-get-the-os-version-in-win8-1-as-getversion-getversionex-are-deprecated) – Remigius Stalder Jun 29 '15 at 09:34
  • This is not a duplicate. In that question a solution for getting the OS is asked. I'm asking whether it's safe or not to get this info from the registry. I see no mention of registry what-so-ever in the other question. – conectionist Jun 29 '15 at 11:06
  • "*Apparently it returns wrong values (corresponding to Windows 8) if called on a windows 8.1 or 10 machine*" - only if your application does not contain a compatibility manifest for those versions. Read the documentation more carefully. `GetVersionEx()` is manifest-aware now. If your app does not explicitly claim to support Windows 8.1 or 10, then `GetVersionEx()` will not report them anymore. Bu if your app claims to support them, `GetVersionEx()` will report correct information for them as expected. – Remy Lebeau Jun 29 '15 at 19:20
  • I am aware of that. But still, the documentation clearly states that "GetVersionEx may be altered or unavailable for releases after Windows 8.1". If it won't **exist** anymore at some point, altering the manifest would be pretty much pointless, now wouldn't it? – conectionist Jun 30 '15 at 08:33

1 Answers1

1

Is there any reason I should avoid doing this?

It is plausible that a future version of Windows will not contain the information that you need in that registry key.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490