How to read windows build version via a Win API call or (better) reading a Registry value

537 Views Asked by At

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.

2

There are 2 best solutions below

2
On

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.

2
On

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.