EnumSerialPorts Method
Refreshes information about serial ports and returns their number.
Syntax
Delphi | function EnumSerialPorts(): Word; |
---|---|
BCBuilder | Word EnumSerialPorts(); |
Parameters
None.
Errors
The method may throw exception. Refer to Handle errors sample for details.
Remarks
To retrieve information about each serial port, use GetSerialPort.
Code Example
var i: integer; PortName: string; PortsCount: Word; begin try PortsCount := FTSPCControl1.EnumSerialPorts(); if PortsCount > 0 then begin for i := 0 to PortsCount - 1 do begin PortName := FTSPCControl1.GetSerialPort(i); // Todo: add your code end; end; except on e:FTSPCException do begin application.MessageBox( PChar('Error: ' + inttostr(e.ErrorCode) + ' - ' + e.ErrorSource), 'Error!', MB_OK + MB_ICONERROR); end; end; end;