How can I determine the names of the installed comm ports?

The following example demonstrates enumerating the communications ports that are installed and listed in the Win32 registry.

 

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 ;

你可能感兴趣的:(How can I determine the names of the installed comm ports?)