CreateTwinPortEx Method
Creates virtual serial port twin with non-standard name and allows replacing the value of FriendlyName and CompanyName (indicated by the license key) with alternative values.
Custom license key is needed to unlock this method. Otherwise it fails.
Syntax
Visual Basic | Sub CreateTwinPortEx(PortName As String, Alias As String, FriendlyName As String, CompanyName As String) |
---|---|
Delphi | procedure CreateTwinPortEx(PortName: String, Alias: String, FriendlyName: String, CompanyName: String); |
Visual C++ (MFC) | void CreateTwinPortEx(LPCTSTR PortName, LPCTSTR Alias, LPCTSTR FriendlyName, LPCTSTR CompanyName); |
Visual C++ (#import) | void CreateTwinPortEx(_bstr_t PortName, _bstr_t Alias, _bstr_t FriendlyName, _bstr_t CompanyName); |
Parameters
PortName
[in] The name of virtual serial port (e.g. "COM1", "VSP25", "SERPORT10" etc). Names "COM0", "COM4294967295" and "LPTx" are prohibited.
Alias
[in] Alias name for existing COM port. You still will be able to open existing COM port using this alias name. The string is an MS-DOS path (e.g. PORT1, COM100).
FriendlyName
[in] FriendlyName Value. If NULL – the value integrated into the license key is used. Can be set only if any FriendlyName is integrated into the license key, otherwise it fails with ftvspcErrorInvalidLicense error.
CompanyName
[in] Company name. If NULL - the value integrated into the license key is used. Can be set only if any FriendlyName is integrated into the key, otherwise it fails with ftvspcErrorInvalidLicense error.
Return
TRUE - the port has been created successfully, FALSE otherwise.
Errors
The method may throw exception. Use GetLastError method to get the error code.
ftvspcErrorFailed | 1 | The operation has not been completed. |
---|---|---|
ftvspcErrorInvalidParameter | 2 | Invalid parameter. |
ftvspcErrorInvalidLicense | 5 | Invalid license. |
ftvspcErrorPortAlreadyExists | 100 | This port already exists. |
Remarks
Port twin is an overlapped virtual serial port created over the physical serial port and existent only when the physical port exists.
Once created, port twin is available for enumeration by EnumVirtual function but does not exist in the system (does not visible in the device manager). It appears in the system only if corresponding physical port appears. When physical port is removed from the system, port twin is removed too.
Port twin can be permanent. In this case it will be available for enumeration by EnumVirtual function at each system startup and will exist in the system if corresponding physical port exists.