Главная страница | назад





Article #16774: How can I determine the names of the installed comm ports?

 Question and Answer Database
FAQ1774D.txt How can I determine the names of the installed comm ports?
Category :Windows API
Platform :All
Product :All 32 bit
Question:
How can I determine the names of the installed comm ports?
Answer:
The following example demonstrates enumerating the communications
ports that are installed and listed in the Win32 registry.
Example:
uses Registry;
procedure TForm1.Button1Click(Sender: TObject);
var
reg : TRegistry;
ts : TStrings;
i : integer;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.OpenKey('hardware\devicemap\serialcomm',
false);
ts := TStringList.Create;
reg.GetValueNames(ts);
for i := 0 to ts.Count -1 do begin
Memo1.Lines.Add(reg.ReadString(ts.Strings[i]));
end;
ts.Free;
reg.CloseKey;
reg.free;
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99