Click here to Skip to main content
13,506,186 members
Click here to Skip to main content
Add your own
alternative version


5 bookmarked
Posted 18 Dec 2011

Another Way to Get Windows XP OS Bit Version in VB.NET

, 9 Apr 2017
Rate this:
Please Sign up or sign in to vote.
How to get Windows XP OS bit version in VB.NET.

This little project is the result needing a way to identify Windows XP bit version for another program I wrote.

While trying to help my mom with a problem with her computer over the phone, I decided to have her download a copy of one of my programs to help identify what OS she was running. When she ran the program, it came back with an error of “Not Found”. After a few minuets, I remembered that it was a WMI error for when you try to get information from a property that the class does not support or contain. Windows XP does not support the Win32_OperatingSystem class property OSArchitecture. (OS Class Found Here on MSDN) The Property was added in Windows Vista.

I ran across another MSDN page that showed that Windows XP Versions of 5.1 for regular and 5.2 For 64 bit version.

There are also  3 server versions listed on that page for Version 5.2

My solution is to check the major and minor version and if the major version is = to 5 and the minor version is = 2 and “OSFullName” contains “Windows XP” then that makes the bit version = to 64 bit. if the Major version = 5 and minor = 1 then 32 bit. (see code below)

Note: This code does not check Server Versions with Major version of 5 and minor version of 2, I currently have no way to test them.

Here is what the program looks like in Vista 64 bit and XP 32 bit (VM).



I think it is interesting on how the exact same programs displays differently in Vista and XP. Below is the code for this little program. I won’t be putting this one online but will be fixing my other one with some of the code contained here.

Remember to add your references for System and System.Management.

Imports System
Imports System.Management

Public Class Form1

    Private Sub btnGetVersion_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles btnGetVersion.Click
        Dim OSName As String
        Dim MajorVersion As String
        Dim MinorVersion As String
        Dim SpMajorVersion As String
        Dim SpMinorVersion As String
        Dim OSBitVersion As String
        OSBitVersion = Nothing

        OSName = My.Computer.Info.OSFullName
        MajorVersion = Environment.OSVersion.Version.Major
        MinorVersion = Environment.OSVersion.Version.Minor
        SpMajorVersion = Environment.OSVersion.Version.MajorRevision
        SpMinorVersion = Environment.OSVersion.Version.MinorRevision

        ListBox1.Items.Add("OS Full Name: " & OSName.ToString)
        ListBox1.Items.Add("Major Version: " & MajorVersion.ToString)
        ListBox1.Items.Add("Minor Version: " & MinorVersion.ToString)
        ListBox1.Items.Add("SP Major Version: " & SpMajorVersion.ToString)
        ListBox1.Items.Add("SP Minor Version: " & SpMinorVersion.ToString)

        If MajorVersion.ToString = "5" And MinorVersion.ToString = _
                "2" And OSName.Contains("Windows XP") Then
            OSBitVersion = "64 Bit" ElseIf MajorVersion.ToString = _
                "5" And MinorVersion.ToString = "1" Then
            OSBitVersion = "32 Bit" ElseIf MajorVersion >= 6 Then
                Dim searcher As New ManagementObjectSearcher("root\cimv2", _
                    "SELECT * From Win32_OperatingSystem")

            For Each queryObj As ManagementObject In searcher.Get()
                OSBitVersion = queryObj("OSArchitecture")
            Next Else
            OSBitVersion = "Bit Version Unknown" End If
    End Sub
    Private Sub LinkLabelOSVERSIONINFOEXstructure_LinkClicked(ByVal sender As _
       System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
       Handles LinkLabelOSVERSIONINFOEXstructure.LinkClicked
        Process.Start("Iexplore.exe", _
    End Sub
    Private Sub lblAbout_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles lblAbout.Click

    End Sub
    Private Sub LinkLabelWin32_OperatingSystem_LinkClicked(ByVal sender As _
            System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
            Handles LinkLabelWin32_OperatingSystem.LinkClicked
        Process.Start("Iexplore.exe", _
    End Sub
End Class

I added link labels for the two sites listed above to quickly navigate to the right pages from the program. This also a reminder that XP still thrives on a lot of systems.

Well that’s all there is to the code. If anyone could test it and let me know if you broke it, please let me.

Just post a comment

Thank you for your time.

Edit:09/04/2017 Reomoded links to website I no longer have.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

CEO PC's Xcetra
United States United States
My first experience with computers was when my mom gave a Timex Sinclair 1000 to me for Christmas some time in the late 70's (I still have it)There I learned to copy code from magazines to save to cassette tapes for playing games.

Since then I have dabbled in:
Basic,Qbasic,ruby,python,Java Script, HTML, CSS, C#, C++, Perl, and a few other I can't think of off hand.
Now I Mainly work with VB Script and VB.Net
I Prefer to build programs that make use of the GUI so I don't have to remember all of the syntax for console apps. I realy don't care much for HTML because of the way you build and then run to see if it looks right. Also the new WPF is to much like HTML so I steer clear of it for now.
Most of what I build is for getting information from a system to use in system repair.I make heavy use of the WMI classes. Why reinvent something.

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180417.1 | Last Updated 9 Apr 2017
Article Copyright 2011 by ledtech3
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid