可以读注册表就可以查
procedure QuerySystemComs(ComStrings: TStrings);
var
TmpReg: TRegistry;
TmpPath, TmpKey, TmpComName: string;
i: Integer;
Info: TRegKeyInfo;
begin
TmpReg := TRegistry.Create;
ComStrings.Clear;
try
TmpReg.RootKey := HKEY_LOCAL_MACHINE;
TmpPath := '/HARDWARE/DEVICEMAP/SERIALCOMM';
if TmpReg.OpenKeyReadOnly(TmpPath) and TmpReg.GetKeyInfo(Info) then
begin
for i := 0 to Info.NumValues - 1 do
begin
TmpKey := Format('/Device/Serial%d', );
TmpComName := TmpReg.ReadString(TmpKey);
if TmpComName <> '' then
ComStrings.Add(TmpComName);
end;
end;
finally
TmpReg.Free;
end;
end;