Delphi – Enumerating a List of systems Com Ports in Delphi

delphiregistryserial-portwinapi

Objective: I would like to be able to list the available COM Ports on a system in Delphi.

Homework:
I have read this SO thread on enumerating the LPT ports of a system using the registry. I have also found that the COM ports are listed in the registry at HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM but found unanswered gesticulation in the same thread that this might not be reliable on different machines and different versions of windows.

I also found articles referencing the use of QueryDosDevice() but upon trying this sample code, I found that it did not appear to list any COM ports at all.

Question: What is the most reliable way (across unknown Windows Versions) to list the COM ports on a Windows Machine?

Best Answer

DEVICEMAP\SERIALCOMM is good for all NT versions. You'll probably need to look under DYN_DATA for Win9x.

Use this method if you need runtime reliability.

Related Topic