Click here to Skip to main content
15,892,927 members
Articles / Programming Languages / Visual Basic

Retrieving Information From Windows Management Instrumentation

Rate me:
Please Sign up or sign in to vote.
4.93/5 (39 votes)
15 Jul 2010CDDL15 min read 85.6K   7.4K   62  
How to use WMI to get system information and present it to the user in an easy to understand format.
Option Strict On
Option Explicit On

Public Class UserControlEnvironmentVariables

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        GetEnvironmentVariables()

    End Sub

    Private Sub GetEnvironmentVariables()

        Dim variables As IDictionary = Environment.GetEnvironmentVariables()

        For Each variable As DictionaryEntry In variables
            Dim lvi As New ListViewItem

            lvi.Text = variable.Key.ToString
            lvi.SubItems.Add(variable.Value.ToString)
            lstEnvVariables.Items.Add(lvi)
        Next

    End Sub

    Public Sub CollectReportData()

        Dim newReport As TextReport = FormMain.TextReportFile
        Dim variables As IDictionary = Environment.GetEnvironmentVariables()

        newReport.WriteItem("Variable", "Value")

        For Each variable As DictionaryEntry In variables
            newReport.WriteItem(variable.Key.ToString, variable.Value.ToString)
        Next

    End Sub

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


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

Comments and Discussions