Reading names of comports [COM1, COM2 etc]



I am attempting to read the names of the known com ports on my computer
using the following function. While it appears to work, the names of the com
ports displayed in a list box are NOT COM1, COM2, etc but \Device\Serial0.
\Device\Serial1, etc. I am adding the values returned in PortList to the
listbox with:

for i := 0 to PortList.Count -1 do
lstComPorts.Items.Add(PortList.Strings[i] )

I want to see COM1, COM2 etc. What am I doing wrong?

Any enlightenment will be appreciated.

Vic Fraenckel

Here is the function in question

function GetAllSerialPorts(Var PortList : TStringList) : integer;

//This function reads the registery and extracts the names of
//the known serial ports on your computer.
//The function returns:
// WICNOERROR if successful
// WICCOMPORTERROR of an error is detected

var
i:integer;
itemct : integer;
reg : TRegistry;

begin
reg := TRegistry.Create;

try
begin
reg.RootKey := HKEY_LOCAL_MACHINE;
if not reg.KeyExists ('HARDWARE\DEVICEMAP\SERIALCOMM') then
begin
result := WICCOMPORTERROR;
exit;
end;
if not reg.OpenKey ('HARDWARE\DEVICEMAP\SERIALCOMM',false)then
begin
result := WICCOMPORTERROR;
exit;
end
else
reg.GetValueNames (PortList);
end; //try

finally
reg.Free;
end;
result := WICNOERROR;

end;


--
________________________________________________________

Victor Fraenckel - The Windman
victorf ATSIGN windreader DOTcom
KC2GUI


.