delphi 获取串口列表

procedure TMainF.GetComPorts();
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);


  // self.mmo1.Lines.AddStrings(ts);
  for i := 0 to ts.Count - 1 do
  begin
    self.cbb_comm_list.Items.Add(reg.ReadString(ts.Strings[i]));
  end;
  ts.Free;
  reg.CloseKey;
  reg.Free;
end;

你可能感兴趣的:(delphi)