Reading names of comports [COM1, COM2 etc]
- From: "Vic Fraenckel" <victor522@xxxxxxxxxxxx>
- Date: Sat, 06 Aug 2005 17:09:53 GMT
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
.
- Follow-Ups:
- Re: Reading names of comports [COM1, COM2 etc]
- From: robert_marquardt
- Re: Reading names of comports [COM1, COM2 etc]
- From: Ekkehard Domning
- Re: Reading names of comports [COM1, COM2 etc]
- From: alanglloyd
- Re: Reading names of comports [COM1, COM2 etc]
- From: Jamie
- Re: Reading names of comports [COM1, COM2 etc]
- From: Rob Kennedy
- Re: Reading names of comports [COM1, COM2 etc]
- Prev by Date: shift tray icon position - xp
- Next by Date: Re: Reading names of comports [COM1, COM2 etc]
- Previous by thread: shift tray icon position - xp
- Next by thread: Re: Reading names of comports [COM1, COM2 etc]
- Index(es):