Hi
You are so right
No serial port but I want to use USB with adapter for that.
By the way serial ports with 9-pins or 32-pins are rare on PC's these days.
I need to do a serial protocol called OSM6 on top of a RS-485 hardware setup.
Buttomline is that I want my users via a combox to select the usb ports avaiable on the computer.
As far as I understand you want to connect 2 PCs with USB/RS-232 dongles. In that case you don't need USB ports scanned, you'll need to list the available
serial ports.
The common case with the contemporary computers with no serial ports included, there is a big chance to have only one serial port available - namely that of the dongle.
You can use QueryDosDevice() (in Windows) for searching:
uses
Windows, Math {for IfThen};
const
BUFSIZE = 1024;
function EnumComPorts: TStringList;
var
lpTargetPath: PChar;
I: Integer;
begin
lpTargetPath := GetMem(BUFSIZE);
try
Result := TStringList.Create;
for I := 1 to 99 do
if QueryDosDeviceA(PChar('COM' + IntToStr(I)), lpTargetPath, BUFSIZE) > 0 then
Result.Add(IfThen(I < 10, '', '\\.\') + 'COM' + IntToStr(I));
finally
FreeMem(lpTargetPath);
end;
end;
Edit: As long for RS-485 - If your communication is half-duplex and you don't have a dedicated hardware, you can't expect nominal operation since in Windows there is no adequate way to control the direction of the RS-485 trancievers.