שתף באמצעות


Getting the version of Windows from vb.net

Question

Saturday, August 1, 2015 6:35 PM

I've just upgraded my laptop to Windows 10, most things are working as expected except for one of my applications; it reports the version of Windows it's running under as Windows 8.1. 

To detect the version number, my program extracts the value of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion - which returns 6.3 under Windows 10, the same as windows 8.1.

I've also tried this Microsoft example program:

https://code.msdn.microsoft.com/windowsapps/Sample-to-demonstrate-how-495e69db

Which also shows the version of Windows as 8.1 - not 10.

So, how do I distinguish between 8.1 and 10 from within vb.net.

-Andrew

AndrewFromEssex

All replies (5)

Saturday, August 1, 2015 7:36 PM ✅Answered

Thanks for the reply; the OS is reported as Windows 10 in control panel. My concern is the application has to run from XP to 10 - and detect the Windows version; using the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion for all versions before 10 did return a different string for each version, but not for 10. 

AndrewFromEssex

I understand. I believe if you read the links I provided then information will be available for your app to be able to detect the Windows version. Though the detection method may not directly be using the registry according to how you want to get the information.

With regard to the registry on Windows 10 and where the version information is located in order for you to retrieve it programmatically you should search the net or ask in some other forum since the location of that information and whether it is inaccurate or not is not directly a VB.Net related issue.

Accessing the registry in VB.Net is one issue. Results for values returned from the registry is a Windows issue. Since the values are being retrieved and I suppose if you use Regedit the values are the same as what is being retrieved then until you can find the values you want using Regedit or something I wouldn't consider this a VB.Net issue.

Update: I'm not searching about this anymore but quoted from this link GetVersionEx function in the Community Editions someone mentions the below.

"2.Check the Windows build version in registry(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\BuildLabEx)"

La vida loca


Saturday, August 1, 2015 8:13 PM ✅Answered

What does this code fragment report ?

TextBox1.AppendText("OS         : " & My.Computer.Info.OSFullName & vbNewLine & _
                            "Version    : " & My.Computer.Info.OSVersion & vbNewLine &
                            "Platform   : " & My.Computer.Info.OSPlatform & vbNewLine)

Here (Win 7/32) I get:

OS         : Microsoft Windows 7 Ultimate 
Version   : 6.1.7601.65536
Platform  : Win32NT


Saturday, August 1, 2015 6:53 PM

Does Windows 10 have control panel still? If so what does Control Panel list for the current O/S?

Update: Also see Operating System Version

"* For applications that have been manifested for Windows 8.1 or Windows 10. Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). To manifest your applications for Windows 8.1 or Windows 10, refer to Targeting your application for Windows."

Update2: Also see Manifest Madness - Below manifest ID for Win 10 is from link.

<!-- Windows 10 -->
 <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>

La vida loca


Saturday, August 1, 2015 7:11 PM

Thanks for the reply; the OS is reported as Windows 10 in control panel. My concern is the application has to run from XP to 10 - and detect the Windows version; using the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion for all versions before 10 did return a different string for each version, but not for 10. 

AndrewFromEssex


Saturday, August 1, 2015 8:59 PM

Thanks for the reply; that returns

OS         : Microsoft Windows 10 Home
Version    : 6.3.9600.0
Platform   : Win32NT

ISTR there was a problem using this for earlier versions - although I can't remember what that was now; I think my solution is to spot 26.3 as the version code then use the OSFullName to distinguish between 8.1 and 10.

-Andrew

AndrewFromEssex