I do a slight cheat which seems to work at the moment but WMI is probably a better option.
Here is my whole routine but its only the first three lines that find the ports and organise them into an array. remember to add "\\.\" before the port name as ports over a certain number (which I cant remember) require it, so I add it to them all.
Function GetComPorts(CBHNDL As DWord)
Local N,M As DWord
Local nIdx As DWord
Local Buffer As String
Local Ports() As String
If Registry_PathExists("HKEYLM", "hardware\devicemap\serialcomm") Then
Buffer = Registry_GetAllKeys("HKEYLM", "hardware\devicemap\serialcomm")
Split(Buffer,$CRLF,Ports)
If UBound(Ports) <> UBound(ComPorts) Then
'---To minimize video redraw, better to stop control updates
ListView_BeginUpdate CBHNDL, %LvwDisp1
ListView_DeleteAllItems(CBHNDL, %LvwDisp1)
ReDim ComPorts(UBound(Ports))
For n = 1 To UBound(Ports)
ComPorts(n) = Remain$(Ports(n),"=")
ListView_InsertItem CBHNDL, %LvwDisp1, n, 1, ""
ListView_SetItem CBHNDL, %LvwDisp1, n, 2, ComPorts(n)
ListView_SetCheckState CBHNDL, %LvwDisp1, n, %TRUE
Next
'---To minimize video redraw, better to stop control updates
ListView_EndUpdate CBHNDL, %LvwDisp1
EndIf
EndIf
End Function
Bookmarks