My.Computer.Info.OSFullName

StewartBW 1,830 Reputation points
2025-03-12T23:57:36.56+00:00

Hello

Seems just like VB6, getting the OS Full Name is still challenging in .NET Framework!

Possible to throw exception based on the WMI, possible to return the My.Computer.Info.OSPlatform instead which is useless, and will return the full name based on the user's culture, ie:

Майкрософт Windows 8.1 Профессиональная 6.3.9600.0

Now, possible to get the My.Computer.Info.OSFullName in language invariant?

And is the following string always stored in English or this one will also be localized?

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion :: ProductName

Any better alternative?

Thanks :)

Developer technologies | VB
{count} votes

Accepted answer
  1. Castorix31 90,686 Reputation points
    2025-03-13T09:17:07.5533333+00:00

    And is the following string always stored in English or this one will also be localized?

    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion :: ProductName

    It does not seem localized on my french OS : I get "Windows 10 Education" while with other APIs, like BrandingFormatString from Winbrand.dll, I get "Windows 10 Éducation" (with accent, meaning it is localized)

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2025-03-13T07:56:24.08+00:00

    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.