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

MuldeR mulder2 at gmx.de
Wed Oct 23 14:35:44 CEST 2013


Indeed.

IMO, the purpose of GetVersionEx() and especially QSysInfo::windowsVersion() should be detecting the *actual* operating system version that we are running on.

With the "manifest workaround" the GetVersionEx() function is crippled to reporting (at most) the highest Windows version supported by the calling app, according to it manifest. But that is a NOP operation! That's because I already know which Windows versions my application is verified to run on - at compile time. How else could I have written it into the manifest? So, if GetVersionEx() only tells my what I have written into the manifest, why do I need to call it all - at runtime? It's kind of pointless.

(And, honestly, how can anybody know that QSysInfo::windowsVersion() reports "wrong" information on Windows versions, except when a specific manifest is added to the binary? How many apps do add such a manifest at all?)

Regards,
MuldeR

On 23.10.2013 07:31, Chris W wrote:
> Using the manifest kludge only delays the problem.  When the next 8.x 
> version of Windows is released GetVersionEx will presumably resume lying 
> to Qt/your application about the Windows version you are running.  Which 
> version it gives you is anyone's guess.
>
>
> On 21/10/13 04:47, Raul Metsma wrote:
>> Why not use the manifest workaround?
>>
>> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
>>      <application>
>>           *  <!-- Windows 8.1 -->
>>           *  <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
>>
>> Raul
>>
>> On Oct 20, 2013, at 4:56 PM, MuldeR <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
>>> http://lists.qt-project.org/mailman/listinfo/development
>> _______________________________________________
>> Development mailing list
>> Development at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/development
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>


-- 
http://www.youtube.com/watch_popup?v=Jay-fG9eaYk#!



More information about the Development mailing list