Hi @StewartBW ,
My.Computer.Info.OSFullName
retrieves the OS name based on the system language, which makes it unreliable if you need a language-invariant result.
The value of HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion :: ProductName is usually stored in English.
You can also use RtlGetVersion function (wdm.h) to get the Windows versions.
<StructLayout(LayoutKind.Sequential)>
Public Structure OSVERSIONINFOEX
Public dwOSVersionInfoSize As Integer
Public dwMajorVersion As Integer
Public dwMinorVersion As Integer
Public dwBuildNumber As Integer
Public dwPlatformId As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)>
Public szCSDVersion As String
End Structure
<DllImport("ntdll.dll", SetLastError:=True)>
Private Shared Function RtlGetVersion(ByRef versionInfo As OSVERSIONINFOEX) As Integer
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim osvi As New OSVERSIONINFOEX()
osvi.dwOSVersionInfoSize = Marshal.SizeOf(osvi)
If RtlGetVersion(osvi) = 0 Then
Console.WriteLine($"Windows {osvi.dwMajorVersion}.{osvi.dwMinorVersion} (Build {osvi.dwBuildNumber})")
Else
Console.WriteLine("Failed to get OS version.")
End If
End Sub
Best Regards.
Jiachen Li
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.