| 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] |