65.9K
CodeProject is changing. Read more.
Home

Operating System Information

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.20/5 (10 votes)

Jun 23, 2005

viewsIcon

48276

downloadIcon

867

An article on finding the OS name and OS language.

Sample Image

Introduction

This code finds OS information, i.e., it finds the name of the OS which is installed in your machine and the language of the OS.

Using the code

This code uses the WqlObjectQuery to find OS information. It uses the namespace System.Management. What is does is it basically finds the locale of the OS which is specific for a particular language of the OS. It actually queries the table win32_OperatingSystem which comes up with the operating system to find the OS name and the locale of the OS. This code runs on both 32 bit and 64 bit OS if there is .NET framework installed in the OS. For example, I make the code to find the locale of 8 different languages like English, German, French, Russian, Spanish, PortBraz, Polish and Italian. Any locale can be added to the code to find the OS Language.

Dim objectQuery As New WqlObjectQuery("select * from win32_OperatingSystem")
Dim searcher As New ManagementObjectSearcher(objectQuery)
Dim share As ManagementObject
Dim a As String
Dim os As String
For Each share In searcher.Get()
    a = share("Name")
    Dim split1 As String()
    split1 = Split(a, "|")
    os = split1(0)
    TextBox2.Text = os
    Button2.Text = os
Next share

For Each share In searcher.Get()

    a = share("Locale")
    If a = "0409" Then
        TextBox1.Text = "English"
        Button1.Text = "English"
    ElseIf a = "0407" Then
        TextBox1.Text = "German"
        Button1.Text = "German"
    ElseIf a = "040a" Then
        TextBox1.Text = "Spanish"
        Button1.Text = "Spanish"
    ElseIf a = "040c" Then

Points of Interest

This code is useful for GUI translation. Using this code one can translate the GUI to any specific language.