Bill_Stewart
Bill_Stewart

Reputation: 24525

Will Win32 GetVersionEx API with application manifest break in later version?

I have a program that reports and/or detects the Windows OS version. It uses GetVersionEx, but Microsoft intentionally broke this API in Windows 8.1 and later to return incorrect version information. (Apparently proper version checking is just too hard for the masses to get right, but that's a rant for another topic.)

I know that I can add a manifest to work around this particular problem, but my question is about "future-proofing" the program.

If a future user runs the program on a newer OS than Windows 10, will GetVersionEx work correctly and report the "real" OS version, even if the program's manifest doesn't include that version's GUID?

Or am I doomed to continually add new GUIDs to the manifest every time a new OS version is released?

Upvotes: 0

Views: 921

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 595837

If a future user runs the program on a newer OS than Windows 10, will GetVersionEx work correctly and report the "real" OS version, even if the program's manifest doesn't include that version's GUID?

NO, and this is documented behavior:

With the release of Windows 8.1, the behavior of the GetVersionEx API has changed in the value it will return for the operating system version. The value returned by the GetVersionEx function now depends on how the application is manifested.

Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). Once an application is manifested for a given operating system version, GetVersionEx will always return the version that the application is manifested for in future releases. To manifest your applications for Windows 8.1 or Windows 10, refer to Targeting your application for Windows.

Or am I doomed to continually add new GUIDs to the manifest every time a new OS version is released?

Sadly, YES. The point of version manifestation is to explicitly report the OS version(s) that your app is known to be compatible with. Obviously you can't know ahead of time if it is compatible with future versions. So, whenever a new version is released, you test your app as needed, verify it working (and fix it if needed), and then update the manifest accordingly. Until then, Windows will down-grade itself to behave like the highest OS version that you have reported in your manifest.

You should not be relying on GetVersionEx() to control your app's functionality at runtime anyway. It is fine for reporting the OS version in logs and such (and there are other ways to get the true OS version regardless of manifestation), but don't make decisions based on OS version. For instance, if want to use a given feature that is only available in recent OS versions, don't check the OS version, check for the existence of the feature itself and use it if it is available.

Upvotes: 1

Related Questions