Getting Hardware Information Using Visual Basic.NET and VBScript - The class Win32 OnBoardDevice in detail
(Page 2 of 4 )
In the previous section, I touched on only some of the most important properties from the existing WMI class (Win32_OnBoardDevice); had I done otherwise, it would have made the program too long. The program above will list the description, device type and tag properties. You can further extend the program with several other properties available in the “Win32_OnBoardDevice” class. You can even refer to MSDN online for further properties.
Now, let us go into the details of the properties I mentioned in the previous section.
Description: This property gives you a better explanation of the object.
Device Type: In general, there will be many types of devices “OnBoard.” The devices include Video, SCSI controller, Ethernet (especially for LAN), and so on. The “Device Type” property explains the type of device being represented. The following is the table extracted from MSDN to provide you with an explanation of those values returned by “Device Type.”
Value | Meaning |
1 | Other |
2 | Unknown |
3 | Video |
4 | SCSI Controller |
5 | Ethernet |
6 | Token Ring |
7 | Sound |
| | |
Enabled: This property specifies whether the device is enabled to work or not. Sometimes, it also depends on hardware settings or configuration.
Tag: This property gives you the unique identifier of the onboard device available for your system.
Listing the processors available
In previous sections, we have seen only “On Board Devices.” Now, let us go through the information related to the processors existing in your system. The following VB.NET code should support retrieving some minimum information about processors available on your system.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_Processor")
Dim dt As DataTable = globals.getProcessorStructure
For Each queryObj As ManagementObject In searcher.Get()
globals.addProcessorDevice(dt, Convert.ToString(queryObj("Availability")), queryObj("Caption"), Convert.ToString(queryObj("CpuStatus")), Convert.ToString(queryObj("CurrentClockSpeed")), queryObj("DeviceID"), Convert.ToString(queryObj("Level")), queryObj("Name"), queryObj("ProcessorId"), Convert.ToString(queryObj("ProcessorType")), queryObj("SystemName"))
Next
Me.DataGrid1.DataSource = dt
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
End Try
End Sub
You can achieve the same thing with VBScript as follows:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Processor",,48)
For Each objItem in colItems
Wscript.Echo "Availability: " & objItem.Availability
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "CpuStatus: " & objItem.CpuStatus
Wscript.Echo "CurrentClockSpeed: " & objItem.CurrentClockSpeed
Wscript.Echo "DeviceID: " & objItem.DeviceID
Wscript.Echo "Level: " & objItem.Level
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "ProcessorId: " & objItem.ProcessorId
Wscript.Echo "ProcessorType: " & objItem.ProcessorType
Wscript.Echo "SystemName: " & objItem.SystemName
Next
Next: The class Win32_Processor in detail >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee