0

Starting with Windows 8.1, GetVersionEx no longer returns the "true" version number, but might return a lower value.

There a no service packs for Windows 8 or Windows 8.1 yet, but when they are available, will GetVersionEx lie about them (wServicePackMajor and wServicePackMinor in OSVERSIONINFOEX) as well?

Heinzi
  • 167,459
  • 57
  • 363
  • 519
  • The change was made _"due to undesirable customer behaviors resulting from how the GetVersion(Ex) APIs have been used in the past"_. Due to you asking this question, I guess you're one of the targeted customers. Use feature detection, not version detection. If you can explain _why_ you need the version number, how you are using it and what specifically you are afraid of breaking when the version number does or does not change when a service pack has been installed, might help getting accurate answers that address your original problem. – CodeCaster Nov 20 '13 at 13:37
  • 1
    @CodeCaster: Objection noted, and I do understand the intention behind this. Still, there are cases where determining the actual version number or service pack level is desirable (think about diagnostics tools, for example), so I still think that the question does have value. – Heinzi Nov 20 '13 at 13:40
  • 1
    @CodeCaster: Since you are curious (although this is unrelated to the technical content of the question): In our case, we contractually guarantee that a certain version of our software will work with certain versions and service pack levels of Windows. As a service to the user, we show a small, nonintrusive message if these conditions are not met. As you can see, the "original problem" is a business/legal requirement, not a technical one. I am not seeking advice on the business/legal requirement here. – Heinzi Nov 20 '13 at 13:55
  • It seems to me the answer is right on the second page you linked. See the info about manifesting 8.1 (and how it won't affect running on previous versions) but will solve your `GetVersionEx()` concern. There's also `VERSIONHELPERAPI` (same page), which adds things like `IsWindows7SP1OrGreater()`, `IsWindows8OrGreater()` and ' IsWindows8_1OrGreater()`; one would presume that when Windows 8.1 SP1 is released, they'll add the corresponding `IsWindows81SP1OrGreater()` to the list, I'd think. – Ken White Nov 20 '13 at 14:18
  • Have you considered using `VerifyVersionInfo`, which is more sincere? http://stackoverflow.com/a/19119582/2604492 – Paul Nov 20 '13 at 15:52

1 Answers1

1

Microsoft forever does battle with well-intended code that a programmer writes to check the Windows version. Which was typically written to deal with older Windows versions. But forgets to do something reasonable with a newer Windows version.

So they spend massive amounts of effort on targeted compatibility shims that intentionally lie about the Windows version when a specific program asks for it. A never-ending battle whenever they release a new Windows version. Certainly a losing battle, the number of programs they need to test is staggering.

So at Windows 8.1 they said "no more", deprecated GetVersionEx() and intentionally lie out of the box, returning version 8.0. You need to add an entry to the manifest to turn off the lie. Which probably will turn off a lie about the service pack as well. Or might require an updated GUID, fairly unlikely. We of course can't be sure until that happens.

Community
  • 1
  • 1
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536