The AttachEx method opens the existing virtual serial port, previously created by CreatePortEx method for the current user session.

BOOL AttachEx(

      BSTR PortName     // name of the virtual serial port

        BSTR IdUserSession // user session ID in which the virtual port is available 

              If a port is created globally, the parameter is equal to an empty string.




  • PortName: [in] Name of the existing virtual serial port to be opened.
  • IdUserSession: User session ID in which the virtual port is available. If a port is created globally, the parameter is equal to an empty string.
Return Values: If the function succeeds, the return value is TRUE. If the virtual serial port does not exist, or no virtual serial bus is present in your system, or the virtual serial port is already assigned to another instance of VSP AX Control, the return value is FALSE.


Note: Use this method when you need to re-establish connection with the existing virtual serial port, which was previously created by another instance of the Control and connection was lost (your application exited without deleting virtual serial port). 
Tip: See also: CreatePortEx method