打印本文 打印本文 关闭窗口 关闭窗口
几个 WMI 的例子(初级) - 1
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2399  更新时间:2009/4/23 18:59:07  文章录入:mintao  责任编辑:mintao
            WMI = Nothing

            Return _WMIList

        Catch ex As Exception

            MsgBox(ex.Message, 16 + 0, ex.TargetSite.Name)

        End Try

    End Function

获取 WMI 的 Class Info 并将其写入输出窗口

    Private Sub GetInfo(ByVal IndexString As String)

        Try

            If IndexString Is Nothing Then Exit Sub

            Dim wmiClass As String = IndexString

            WMI = New Management.ManagementClass(wmiClass)

            Dim strInfo As String

            Console.WriteLine("WMI Class is:" & wmiClass)

            For Each info In WMI.GetInstances

将 WMI Class Info 写到输出窗口

                Console.WriteLine(info.GetText(Management.TextFormat.Mof).ToString)

            Next

            info = Nothing

            WMI = Nothing

        Catch ex As Exception

            MsgBox(ex.Message, 16 + 0, ex.TargetSite.Name)

        End Try

    End Sub

---------------------------------------------------------------------------------------

使用时:

            Dim tmpStr() As String, i As Integer

            ''''获取 WMI 的 Class Name

            tmpStr = FindWMI(Nothing, True)

            ''''列出 Class Name Array 中的第 559 个 Class 的 Info

            GetInfo(tmpStr(559))

            ''''列出物理内存的信息

            GetInfo("Win32_PhysicalMemory")

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口