#include "lm.h" bool GetWindowsVersion(DWORD& major, DWORD& minor) { LPBYTE pinfoRawData; 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; NetApiBufferFree(pinfoRawData); return true; } return false; }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. Main source: http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe
Programming Tips - How can I get the true Windows version since GetVersionEx() is broken?
Date: 2015oct1
Updated: 2016dec6
OS: Windows
Language: C/C++
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: