- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi 获取计算机串口列表
procedure GetSysSerialComm(CommLst: TStrings);
var
reg: TRegistry;
ComList: TStringList;
i: Integer;
begin
ComList:= TStringList.Create;
reg:= TRegistry.Create;
CommLst.Clear;
try
reg.RootKey:= HKEY_LOCAL_MACHINE;
if reg.OpenKey('HARDWARE\DEVICEMAP\SERIALCOMM', false) then
begin
reg.GetValueNames(ComList);
for i:= 0 to ComList.Count -1 do
CommLst.Add(reg.ReadString(ComList[i]));
end;
finally
ComList.Free;
reg.Free;
end;
end;
//调用示例
procedure TForm1.btn1Click(Sender: TObject);
begin
GetSysSerialComm(cbb1.Items);
end;
来源:https://blog.csdn.net/liang08114/article/details/86712626