February 13th, 2004

Bad version number checks

Version numbers. Very important. And so many people check them wrong.

This is why Windows 95’s GetVersion function returned 3.95 instead of 4.0. A lot of code checked the version number like this:

  UINT Ver = GetVersion();
  UINT MajorVersion = LOBYTE(uVer);
  UINT MinorVersion = HIBYTE(uVer);
  if (MajorVersion < 3 || MinorVersion < 10) {
   Error("This program requires Windows 3.1");
  }

Now consider what happens when the version number is reported as 4.0. The major version check passes, but the minor version check fails since 0 is less than 10.

This bug was so rife that we gave up shimming every app that had the problem and just decided, “Fine. If anybody asks, say that the Windows version is 3.95.”

I suspect this is also why DirectX always reports its version as 4.x.

Topics
History

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.