Obtaining available COMM ports in Windows 
Author Message
 Obtaining available COMM ports in Windows

Hello again,

I've searched for this, but my results are usually muddle with unrelated
docs. Is there an easy way? I down{*filter*} Grier's book; however, I can't find
any example of it.

Currently, I go from 1 to 255, testing if the port opens and  each speed
settings. It works, but is way slow.

Thanks,

Rich



Sun, 03 Jul 2005 00:04:14 GMT  
 Obtaining available COMM ports in Windows
Try this:

Private mvarAvailPort() As Boolean
Private Sub GetAvailablePorts()
  ReDim mvarAvailPort(8) ' or 255
  On Error GoTo ErrHandler
  For i = 1 To 8 ' or 255
    mMSCOMM.CommPort = i
    mvarAvailPort(i) = True
    mMSCOMM.PortOpen = True
    mMSCOMM.PortOpen = False
    Do While mMSCOMM.PortOpen = True
        DoEvents
    Loop
  Next i
Exit Sub
ErrHandler:
    mvarAvailPort(i) = False
    Resume Next
End Sub

Later,
Mikkel



Sun, 03 Jul 2005 06:46:59 GMT  
 Obtaining available COMM ports in Windows
Hi Mikkel,

That's basically what I'm doing. The problem being that, for example,
RocketPorts (multi port serial adapters) can have a wide starting range.
Going through each port seems cumbersome.

I do appreciate your feedback!

Thanks,

Rich
www.techarts.com


Quote:
> Try this:

> Private mvarAvailPort() As Boolean
> Private Sub GetAvailablePorts()
>   ReDim mvarAvailPort(8) ' or 255
>   On Error GoTo ErrHandler
>   For i = 1 To 8 ' or 255
>     mMSCOMM.CommPort = i
>     mvarAvailPort(i) = True
>     mMSCOMM.PortOpen = True
>     mMSCOMM.PortOpen = False
>     Do While mMSCOMM.PortOpen = True
>         DoEvents
>     Loop
>   Next i
> Exit Sub
> ErrHandler:
>     mvarAvailPort(i) = False
>     Resume Next
> End Sub

> Later,
> Mikkel



Sun, 03 Jul 2005 23:24:10 GMT  
 Obtaining available COMM ports in Windows
Ok, how about doing the search once during program setup and save the result
in f.ex. an ini file. The portnumbers should not change each time.

Mikkel



Mon, 04 Jul 2005 02:57:59 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Finding available comm ports

2. Api Call to know Available Comm Ports

3. Api Call to know Available Comm Ports

4. Comm - Port not available

5. Comm ports and running Quickbasic programs under windows or NT

6. -Problem- 16 Bit Comm Port Access in Windows NT

7. Comm port access or I/O port access

8. How to loop comm port control to read text files through serial port in VB3

9. HOWTO: obtain list of available computers????

10. HOWTO: obtain list of available computers????

11. Windows Script 5.5 Beta 1 setup for Windows 2000 available

12. Obtaining parallel port address

 

 
Powered by phpBB® Forum Software