QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Billysugger on December 16, 2019, 05:08:17 pm

Title: Finding available COM port numbers
Post by: Billysugger on December 16, 2019, 05:08:17 pm
Hi All,

I am writing a utility which writes data to a device connected to a Virtual COM Port connected by USB.  The trouble is, Windows has a nasty habit of re-assigning COM port numbers to different devices, or even sometimes the same device connected to a different USB port.  So while I can use Device Manager to establish which COM port I am connected to, and hand edit my code to use that port, that won't help eventual users who will run the executable using a device plugged into which ever USB port they choose.  So at runtime, m y code will have no idea which COM port to open.

Does anyone have a good idea how to find the next available COM port number, or which ports are available so I can give the user the option?
Title: Re: Finding available COM port numbers
Post by: visionmercer on December 17, 2019, 07:22:33 am
Hi
This example code in the wiki might help you:
https://www.qb64.org/wiki/Windows_Libraries#Windows_Ports (https://www.qb64.org/wiki/Windows_Libraries#Windows_Ports)
Title: Re: Finding available COM port numbers
Post by: Billysugger on January 02, 2020, 10:01:22 am
Hi
This example code in the wiki might help you:

Thank you!  I'll give that a try :-)