Hi,

I am trying to list out the available ports on the machine using the registry
functions in VB. But the i get an error even while opening the registry.
I have given the code i am using below. If you could find anything wrong
with it please reply.





Dim hKey As Long ' receives a handle to the newly created or opened registry
key
Dim stringbuffer As String ' receives data read from the registry
Dim databuffer(1000) As Byte ' receives data type of read value
Dim slength As Long, dlength As Long, tbuffer As Long ' receives length of
returned data
Dim retval As Long ' return value

' Create or open the registry key
retval = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Hardware\\DeviceMap\\SerialComm",
0, KEY_ALL_ACCESS, hKey)
MsgBox retval

If retval <> 0 Then
Debug.Print "ERROR: Unable to open registry key!"
Exit Sub
End If

beg:
retval = RegEnumValue(hKey, i, stringbuffer, slength, 0&, REG_SZ, databuffer(0),
dbuffer)
MsgBox retval
If retval = 0 Then
Debug.Print stringbuffer
GoTo beg
Else
GoTo closereg
End If
Debug.Print stringbuffer

closereg:
RegCloseKey (hKey)