• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

How to list all COM ports and open available ports without clicking?

Started by Minh-Quang LE, January 24, 2019, 04:58:15 pm

Previous topic - Next topic

Minh-Quang LE

Hi,
I am trying to write a program that can check all the COM ports, try to open existing ports and configure them automatically. The Dterminal example shows how to select a port, activate/disable it through a TnrDeviceBox port, but that way a human has to check and open the port manually.
My idea is to try to open all found ports. If a port is not available, this should generate an error. If not, it could be possible to open and configure it.
However, I cannot find example of how to find the list of all COM port, how to take their names and how to handle the generated error.

In my case, I currently have 2 COM ports at the start of my program. The 1st COM port is a FTDI device (FT232RL) which can be opened by its name. So it remains one free COM port that I have to open with nrComm. The order of COM ports changes from computer to computer, so I have to test in order to determine what COM port is already used and open the other COM port.

Could you give some examples of how to do it?

Thanks a lot

Minh-Quang

Roman Novgorodov

Hello

Please take a look the following demo projects:

Demos\SerialPortInfo\SerialPortInfo.dpr
Demos\Enum\enum_demo.dpr

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.