Link to home
Start Free TrialLog in
Avatar of specialfreckles
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\HARDWARE\DEVICEMAP\SERIALCOMM

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
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of specialfreckles
specialfreckles

ASKER

marconovaro - Thanks for the tip- Worked out great
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\SERIALCOMM"
        .EnumerateValues sKeys(), iKeyCount
        For i = 1 To iKeyCount
            .ValueKey = sKeys(i)
            .ValueType = REG_SZ
            CommPorts.Add .Value
        Next i
    End With
End Sub