EnumSerialPorts Method

Refreshes information about serial ports and returns their number.

Syntax

Visual Basic .NET
Function EnumSerialPorts() As UInt16 
Visual C#
UInt16 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

String PortName = "";

try
{
	UInt16 PortsCount = ftspcControl1.EnumSerialPorts();

	for (UInt16 i = 0; i < PortsCount; i++)
	{
		PortName = ftspcControl1.GetSerialPort(i);

		// Todo: add your code

	}
}
catch (FTSPCException E)
{
	MessageBox.Show("Error " + E.ErrorCode.ToString() + "\r\n" + 
	E.ErrorSource, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}