不知你说的是否是枚举串口?给你一个例程。可以检测可用串口。procedure EnumComPorts(APorts: TStrings);var KeyHandle: HKEY; ErrCode, Index: Integer; ValueName, Data: string; ValueLen, DataLen, ValueType: DWORD; TmpPorts: TStringList;begin ErrCode := RegOpenKeyEx( HKEY_LOCAL_MACHINE, 'HARDWARE/DEVICEMAP/SERIALCOMM', 0, KEY_READ, KeyHandle); if ErrCode <> ERROR_SUCCESS then Exit; // raise ERS232Error.Create(CErrCode); TmpPorts := TStringList.Create; try Index := 0; repeat ValueLen := 256; DataLen := 256; SetLength(ValueName, ValueLen); SetLength(Data, DataLen); ErrCode := RegEnumValue(KeyHandle, Index, PChar(ValueName), Cardinal(ValueLen), nil, @ValueType, PByte(PChar(Data)), @DataLen); if ErrCode = ERROR_SUCCESS then begin SetLength(Data, DataLen); TmpPorts.Add(Data); Inc(Index); end else if ErrCode <> ERROR_NO_MORE_ITEMS then exit; //raise ERS232Error.Create(ErrCode); until (ErrCode <> ERROR_SUCCESS) ; TmpPorts.Sort; APorts.Assign(TmpPorts); finally RegCloseKey(KeyHandle); TmpPorts.Free; end;end;