GetSerialPort Method
Retrieves string value of serial port name.
Syntax
| Visual Basic | Function GetSerialPort(index As Long) As String |
|---|---|
| Visual C++ (MFC) | CString GetSerialPort(long index); |
| Visual C++ (#import) | _bstr_t GetSerialPort(LONG index); |
Parameters
index
[in] Index of serial port (0 ... number_of_ports - 1).
Return
String value representing serial port name.
Code Example
'---------------------------------------------------------------------
' Visual Basic 6 Example
'---------------------------------------------------------------------
On Error GoTo ErrorHandler
Dim i As Integer
Dim nPorts As Integer
Dim PortName As String
nPorts = FTSPCControl1.EnumSerialPorts()
For i = 0 To nPorts
PortName = FTSPCControl1.GetSerialPort(i)
' Todo: add your code
Next i
Exit Sub
ErrorHandler:
Dim err_code As Integer
err_code = FTSPCControl1.GetLastError
MsgBox "ErrorCode = " & CStr(err_code) & " - " & _
Err.Description, vbCritical, "Error!"
/////////////////////////////////////////////////////////////////////
// C++ Example
/////////////////////////////////////////////////////////////////////
CString PortName;
try
{
long nPorts = m_SPCControl1.EnumSerialPorts();
for (int i = 0; i < nPorts i++)
{
PortName = m_SPCControl1.GetSerialPort(i);
// Todo: add your code
}
}
catch(COleDispatchException* E)
{
MessageBox(E->m_strDescription, mbCaption, MB_OK | MB_ICONERROR);
}