This seems to be a remarkably hard thing to do for what seems a relatively common thing. I want to know precisely the version of Windows (i.e. Windows 7 - Professional) and if it's 32 or 64 bit. I also need it to work with future versions of Windows (i.e. 10). How would I go about doing this with C++?
-
possible duplicate of [Check Windows version](http://stackoverflow.com/questions/1963992/check-windows-version) – 500 - Internal Server Error Feb 02 '15 at 23:41
1 Answers
You can use GetVersion
or GetVersionEx
. You can also use the newish version helper functions. Both of these methods mean you will need to write your own logic and supply your own strings based on version numbers. See an implementation of this on this page, you might be able to copy-paste: https://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx
Even though GetVersion*
are considered deprecated, there is no chance of MS actually removing these. Far too many applications rely on them already. My guess is they are discouraging developers from using them, because they have been so misunderstood and misused, they are trying to use a different model for querying OS version information. I would feel totally safe using them though if this is what you need.
To really get a human-readable OS Product description from the OS itself, you can use WMI. Here is an example from MSDN.

- 36,141
- 15
- 83
- 142
-
... be aware that windows often lies about the version for compatibility reasons. – Deduplicator Feb 02 '15 at 23:59
-
Thanks but GetVersionEx is deprecated and the VersionHelper functions don't have way to determine if it's 32 or 64 bit, or if it's home, professional, etc. Also, it seems to just have IsWindows7OrGreater() BOOL style functions. – Dave Weber Feb 03 '15 at 15:56