Need help getting hardware information from registry

rbc827

Member
Joined
May 7, 2007
Messages
17
Programming Experience
Beginner
I'm trying to show all the hardware listed under the following registry key. HKLM\System\ControlSet\Enum

My code will allow me to open the subkeys and get the names of these keys, but what I really want is to go deeper into the subkeys and get the "Class" "DeviceDesc" and "Mfg" of each of the subkeys. I don't know how to do this. Here is my code.

Private Sub ListView3_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListView3.Clear()
ListView3.View = View.Details
ListView3.Columns.Add(
"Class", 200, HorizontalAlignment.Left)
ListView3.Columns.Add(
"Description", 400, HorizontalAlignment.Left)
ListView3.Columns.Add(
"Manfacturer", 200, HorizontalAlignment.Left)
ListView3.Sorting = SortOrder.Ascending
ListView3.FullRowSelect =
True
ListView3.GridLines = True
Dim Key As RegistryKey = Registry.LocalMachine.OpenSubKey _
(
"System\CurrentControlSet\Enum", False)
Dim SubKeyNames() As String = Key.GetSubKeyNames()
Dim Index As Integer
Dim SubKey As RegistryKey
SubKey = Registry.LocalMachine.OpenSubKey(
"System\CurrentControlSet\Enum" + "\" _
+ SubKeyNames(Index),
False)
For Index = 0 To Key.SubKeyCount - 1

Dim item1 As New ListViewItem(CType(SubKey.GetValue("Class", ""), String))
item1.SubItems.Add((SubKey.GetValue(
"DeviceDesc", "")))
item1.SubItems.Add((SubKey.GetValue(
"mfg", "")))
ListView3.Items.AddRange(
New ListViewItem() {item1})

Next
Key.Close()
End Sub
 
Last edited:
I've changed my code to use WMI to get the hardware listed on the computer, but now I need help putting the output into a ListView format. Anyone know how to do this?
 
I figured it out. The problem I was having was adding the subitem to the list. It was a simple fix, but one that took a while to figure out.

item.subitems.add("" + obj)

Without the quotes in front it would fail.
 
Back
Top