I typically use the MSCOMM control for my serial communication. Since my company (offshore surveying) often uses many serial devices into or out of a single computer, the 16-port limitation of this control has always be inconvenient, but I have managed to live with it.
Now, I have purchased an activeX control that lets me create virtual comm ports. This control is very slick and I can communicate with our survey software without any cabling whatsoever. It is easy to create comm ports with this control and my virtual ports are not limited to Comm1 through 16, yahoo!!
Normally, I use the mscomm control to check which ports are available (see code snippet below). This works really well, but I can't see anything above Comm 16. I would like to check the registry for existing Comm ports before I create a virtual comm port with my snazy new control. It wouldn't do to try to create a port that already exists. Does anyone have an idea of how to do this?
Here is the code that checks the first 16 ports with the MSComm control. Note that this particular code adds the comm port (if available) to the listbox, lisports(0).
Now, I have purchased an activeX control that lets me create virtual comm ports. This control is very slick and I can communicate with our survey software without any cabling whatsoever. It is easy to create comm ports with this control and my virtual ports are not limited to Comm1 through 16, yahoo!!
Normally, I use the mscomm control to check which ports are available (see code snippet below). This works really well, but I can't see anything above Comm 16. I would like to check the registry for existing Comm ports before I create a virtual comm port with my snazy new control. It wouldn't do to try to create a port that already exists. Does anyone have an idea of how to do this?
Here is the code that checks the first 16 ports with the MSComm control. Note that this particular code adds the comm port (if available) to the listbox, lisports(0).
Code:
addthisport = True
On Error GoTo set_port_not_avail_flag
For i = 1 To 18
Portcheck.commport = i
Portcheck.PortOpen = True
If addthisport Then 'port is avail
lisPorts(0).AddItem ("COM " + Trim(Str(i)))
End If
Portcheck.PortOpen = False
addthisport = True
Next i
lisPorts(0).ListIndex = 0
Exit Function
set_port_not_avail_flag:
addthisport = False
Resume Next