Reputation: 4929
Every link I look at always mentions GetVersionEx, but that doesn't seem very helpful.
My method looks like this,
static int windowsVersion() {
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
return osvi.dwMajorVersion;
}
Which I am running Windows 8 and instead it returns 6.
If I'm trying to accurately get their version of Windows, that isn't very helpful.
Note: I've also checked all the other variables. the dwMinorVersion returns a 4, build number returns something like 8400.
Upvotes: 1
Views: 3689
Reputation: 52365
A 6
for dwMajorVersion
can mean anything from Windows Vista and up. That's how Microsoft versioning works. 2
for dwMinorVersion
should be either Windows 8 or Windows Server 2012. If wProductType == VER_NT_WORKSTATION
, you got Windows 8. All of this is explained on MSDN.
Upvotes: 3
Reputation: 54562
You need to use both the Major and Minor Version Numbers.
Windows Vista 6.0.6000
Windows 7 6.1.7600
Windows 8 64 bit version on my PC returns 6.2.9200
Upvotes: 3