Browse - Programming Tips - How can I get the true Windows version since GetVersionEx() is broken?
Keywords: deprecated, GetVersion()
Q. How can I get the true Windows version since GetVersionEx() is broken?
A. On Windows 8.1 and later it returns version 8.0
You can do this:
bool GetWindowsVersion(DWORD& major, DWORD& minor)
if (NERR_Success == NetWkstaGetInfo(NULL, 100, &pinfoRawData))
WKSTA_INFO_100 * pworkstationInfo = (WKSTA_INFO_100 *)pinfoRawData;
major = pworkstationInfo->wki100_ver_major;
minor = pworkstationInfo->wki100_ver_minor;
I dynamically load these functions so I don't have to link with Netapi32.lib
Apparently NetWkstaGetInfo() is slower than GetVersionEx() so you can cache its result for the life of your process (since it won't change).
Then you can pass those versions into GetProductInfo() to get a friendly version
or just process them yourself.