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

MuldeR mulder2 at gmx.de
Wed Oct 23 16:03:30 CEST 2013


Sorry,

I don't see how disabling a specific compiler warning, specifically in VS2013, is supposed to fix the changed (broken) behavior of the GetVersionEx() API in Windows 8.1+

Can you elaborate a bit?


On 23.10.2013 14:38, Pau Garcia i Quiles wrote:
> Hello,
>
> As a quickfix, this also works:
>
> #if defined(_MSC_VER) && (_MSC_VER >= 1800)
> #pragma warning (disable:4996)
> #endif
>
>
>
>
> On Sun, Oct 20, 2013 at 3:56 PM, MuldeR <mulder2 at gmx.de <mailto:mulder2 at gmx.de>> wrote:
>
>     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
>
>
>     _______________________________________________
>     Development mailing list
>     Development at qt-project.org <mailto:Development at qt-project.org>
>     http://lists.qt-project.org/mailman/listinfo/development
>
>
>
>
> -- 
> Pau Garcia i Quiles
> http://www.elpauer.org
> (Due to my workload, I may need 10 days to answer)


-- 
http://www.youtube.com/watch_popup?v=Jay-fG9eaYk#!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131023/212de979/attachment.html>


More information about the Development mailing list