1

Our installed is occasionally detecting the wrong version of Windows. (It detects version via built in Wise installer function to detect System Info and doesn't say HOW it does this).

So, I'm looking for another way to detect the Windows version. The Wise installer is pretty limited in it's ability to call Windows API functions so reading from the Registry or a specific file would be easier (of course then I have to map the file version to the Windows version).

I found this discussion thread: http://www.velocityreviews.com/forums/t513244-best-way-to-get-version-from-registry.html But it had no citations. So I'm not sure how dependable it would be.

Clay Nichols
  • 11,848
  • 30
  • 109
  • 170
  • 1
    This could well be intentional, Windows using an appcompat shim. Which will just make you read the same version again. Ping the vendor for support about this. – Hans Passant Nov 03 '11 at 17:48
  • MSI package or a proprietary format? – Cosmin Nov 03 '11 at 17:52
  • It's using the proprietary Wise .exe format (not MSI) – Clay Nichols Nov 03 '11 at 19:29
  • See this question, it may have the answer (the one from Cameron Tinker looks like it might work): http://stackoverflow.com/questions/19058919/how-can-i-find-the-windows-edition-name – rmcsharry Sep 27 '13 at 20:08

2 Answers2

1

I understand you would rather not use the API, but if you don't trust what Wise gives you, it might be the only way to be sure:

GetVersionEx() http://msdn.microsoft.com/en-us/library/ms724451(v=VS.85).aspx

There is sample code (and many comments about alternate functions that might be closer to what you actually need) on the linked to page.

Mike Elkins
  • 1,408
  • 1
  • 11
  • 12
  • This won't report the true (installed) Win O/S version if you're running the app in compatibility mode (for XP) on a Win 7 machine. From Microsoft: "If compatibility mode is in effect, the GetVersionEx function reports the operating system as it identifies itself, which may not be the operating system that is installed. For example, if compatibility mode is in effect, GetVersionEx reports the operating system that is selected for application compatibility." – Clay Nichols Nov 15 '11 at 20:16
  • True, but it will report the version that windows chooses to tell you in order to get you to do the thing you should be doing anyway :) Trying to out-think compatibility mode is generally useful only if you are TRYING to break your application. – Mike Elkins Dec 13 '11 at 21:13
1

If you want a registry solution you can look at the key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion and check out the values for ProductVersion, CurrentVersion, CurrentBuild.

jbudreau
  • 1,287
  • 1
  • 10
  • 22
  • Good idea, but it reported Windows XP (on an Win 7 machine) when I ran the .exe in "Windows compatibility Mode (for XP sp3). – Clay Nichols Nov 15 '11 at 20:16
  • It will be very difficult to avoid that. Compatibility mode will override whatever the underlying OS reports. If you dropped down to a lower level language like C++ it seems you can get the version. See http://msdn.microsoft.com/en-us/library/ms724832(v=vs.85).aspxa – rmcsharry Sep 27 '13 at 20:03