[Development] [Win32 API] Windows 8.1 deprectaed GetVersion(Ex) -> QSysInfo should be fixed!

MuldeR mulder2 at gmx.de
Sun Oct 20 15:56:19 CEST 2013


Hello.

As you might have read, with Windows 8.1, the GetVersion(Ex) API has been deprecated by Microsoft and will now pretend to be Windows 8.0 (NT v6.2), even when running under Windows 8.1 (NT v6.3). And yes, officiallay and in other API's, Windows 8.1 /is/ NT v6.3.

See here for details:
http://msdn.microsoft.com/en-us/library/windows/desktop/dn302074.aspx

Microsoft says that they did this in order to prevent compatibility problems. I think it is a horrible idea to break the API in that way. It is also the reason why Qt happily detects Windows 8.1 as Windows 8. Actually Qt should detect an "unknown" operating system, since there is no 8.1 (NT v6.3 )detection code yet - I have checked latest version in Git. But Qt detects NT v6.2, thanks to Microsoft's GetVersion(Ex) hack. In other words: QSysInfo::windowsVersion() reports *wrong* info, starting with (and probably not limited to) Windows 8.1.

So let's fix QSysInfo!

I have pulled together a solution that is based on the VerifyVersionInfo() API, which has not been broken, fortunately. Basically, we first call GetVersionEx() to get the "fake" version as a starting point. Then we try to increase the version numbers from there, calling VerifyVersionInfo() each time in order to make sure we did not exceed the *real* version. End result will be the maximum supported version, i.e. the *real* version number.


Code is here:
http://pastie.org/private/kkva8pkk7nzcmm8jjwstfa

Tested on: Windows XP (RTM), Windows 7 SP-1, Windows 8.0, Windows 8.1

(should work on Windows 2000 too, but I don't really care)


Output on Windows 7:
> (Fake) Windows Version: 6.1
> Trying to verify: 7.0 -->NO
> Trying to verify: 6.2 -->NO
> *Real* Windows Version: 6.1

Output on Windows 8.0:
> > (Fake) Windows Version: 6.2
> > Trying to verify: 7.0 -->NO
> > Trying to verify: 6.3 -->NO
> > *Real* Windows Version: 6.2

Output on Windows 8.1:
> (Fake) Windows Version: 6.2
> Trying to verify: 7.0 -->NO
> Trying to verify: 6.3 -->YES
> Trying to verify: 6.4 -->NO
> *Real* Windows Version: *6.3*


Regards,
MuldeR

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131020/2ff9cb20/attachment.html>


More information about the Development mailing list