specialfreckles
asked on
How do I enumerate or get all the values for a registry key name
When my program starts up I would like it to list all the serial ports available on its computer
This key name
HKEY_LOCAL_MACHINE\HARDWAR E\DEVICEMA P\SERIALCO MM
On my computer shows
Name Type Data
(Default) REG_SIZE (value not set)
\Device\536ep REG_SIZE COM3
\Device\Serial0 REG_SIZE COM1
\Device\Serial1 REG_SIZE COM2
How can I find out how many entries there are for a key name and present each entry?
This key name
HKEY_LOCAL_MACHINE\HARDWAR
On my computer shows
Name Type Data
(Default) REG_SIZE (value not set)
\Device\536ep REG_SIZE COM3
\Device\Serial0 REG_SIZE COM1
\Device\Serial1 REG_SIZE COM2
How can I find out how many entries there are for a key name and present each entry?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
bruintje- I apprecite the input but it was a little too awkward.
Public RegFunc As New RegistryClass
Private CommPorts As New Collection
Private Sub GetCommports()
Dim sKeys() As String, iKeyCount As Long, i As Integer
Do While CommPorts.Count: CommPorts.Remove 1: Loop
With RegFunc
.ClassKey = HKEY_LOCAL_MACHINE
.SectionKey = "HARDWARE\DEVICEMAP\SERIAL
.EnumerateValues sKeys(), iKeyCount
For i = 1 To iKeyCount
.ValueKey = sKeys(i)
.ValueType = REG_SZ
CommPorts.Add .Value
Next i
End With
End Sub