BT

Your opinion matters! Please fill in the InfoQ Survey!

Version Numbers, Backwards Compatibility, and Windows 10

| by Jonathan Allen Follow 257 Followers on Oct 02, 2014. Estimated reading time: 1 minute |

A note to our readers: As per your request we have developed a set of features that allow you to reduce the noise, while not losing sight of anything that is important. Get email and web notifications by choosing the topics you are interested in.

There is a lot of speculation as to why the next version of Windows will be called “Windows 10”. And while we’ll probably never know what happened behind the closed doors of the marketing department, there are solid technical reasons why it can’t be called “Windows 9”.

To determine if an application can run on a given version of Windows, in full or with limited functionality, most developers check the major and minor version numbers. For example, if your program runs on Windows XP or later you may use this statement:

if (MajorVersion >= 5 && MinorVersion >= 1)

Those of you who worked help desks back in 2006 can probably recognize the error in that code. Windows Vista, which has a version number of 6.0, fails the test. This means many programs ran in either a degraded mode or stopped working entirely, which in turn contributed to Vista’s poor reputation.

Part of the reason Windows 7 was given the version number 6.1 was to suppress this error. And continuing the tradition, Windows 8 and 8.1 were given the numbers 6.2 and 6.3 respectively.

But this isn’t the only mistake that developers have made. A Reddit user going by the handle dndrdndr ran a search for this line of code, which was used to detect Windows 95 and Windows 98:

if (osName.startswith("windows 9"))

According to Search Code, a search engine for open source projects, there are over 4,000 instances of this faulty version checking code. And that’s not counting the untold numbers of commercial and internal applications that may break due to bad version checking.

While writing correct version number checks isn’t hard, the current recommendation from Microsoft is to avoid using GetVersionEx entirely. Instead you can use functions such as IsWindowsXPOrGreater and IsWindowsServer, which are supported all the way back to Windows 2000.

It should be noted that even GetVersionEx was created in response to developers incorrectly checking version numbers. From the documentation for GetVersion,

The GetVersionEx function was developed because many existing applications err when examining the packed DWORD value returned by GetVersion, transposing the major and minor version numbers. GetVersionEx forces applications to explicitly examine each element of version information. VerifyVersionInfo eliminates further potential for error by comparing the required system version with the current system version for you.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

GetVersionEx() has changed in Windows 8.1 by Erwin Richard

Also, note that the behaviour of GetVersionEx() has changed in Windows 8.1. It will return the same as Windows 8.0 unless you specify compatibility with 8.1 in the applications manifest.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT