Click here to Skip to main content
15,868,016 members
Articles / Programming Languages / Visual Basic
Tip/Trick

WMI Reader

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
12 Sep 2012CPOL 10.7K   799   9  
WMI Reader, also includes known WMI list.

Introduction 

Image 1

Image 2

WMI (Windows Management Instrumentation) provides programmers with information about the Operating System. This project includes the known WMI list.

Using the code

The Wmis.csv file contains the WMI paths like this:

  • Keyboards and Pointing Devices;Win32_Keyboard
  • Keyboards and Pointing Devices;Win32_PointingDevice
  • Mapped Drives and File Shares;Win32_ConnectionShare
  • Mapped Drives and File Shares;Win32_LogicalShareAccess
VB
Private Sub LineUp()
    Const FileName As String = "WMIs.csv"

    Using fs As New FileStream(FileName, FileMode.Open)
        Using sr As New StreamReader(fs)
            While (sr.Peek > -1)
                Dim Line As String = sr.ReadLine
                Dim params() As String = Line.Split(";")
                Dim RootNode As TreeNode

                If Not twWMIs.Nodes.ContainsKey(params(0)) Then
                    Dim newNode As New TreeNode(params(0))
                    newNode.Name = params(0)

                    twWMIs.Nodes.Add(newNode)
                    RootNode = newNode
                Else
                    RootNode = twWMIs.Nodes.Find(params(0), False)(0)
                End If

                ' Set Nodes
                Dim WMINode As New TreeNode(params(1))
                WMINode.Name = params(1)

                RootNode.Nodes.Add(WMINode)
            End While
        End Using
    End Using
End Sub

Points of Interest

You can use WMI to learn information about your computer, Operating System, etc... For example, network card mac address, installation date of OS, processor ID, etc... Please be sure to use the UAC settings. You may need the admin rights while reading some WMI information...

License

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


Written By
Software Developer
Turkey Turkey
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --