Virtual Serial Port Tools - Advanced serial port configurations for your custom ports usage scenario
Download Virtual Serial Port Tools Hide this button

IVirtualSerialLibrary Interface

interface IVirtualSerialLibrary {

    // Methods
    ${getPortsJs}(): ${IVirtualSerialDevice}[];
    ${createDevice}(portName?: string | number): ${IVirtualSerialDevice};
}
public interface IVirtualSerialLibrary
{

    // Methods
    Array ${getPorts}();
    ${IVirtualSerialDevice} ${createDevice}(object portName);
    void ${addListener}(${IVirtualSerialLibraryListener} listener);
    void ${removeListener}(${IVirtualSerialLibraryListener} listener);
}
struct IVirtualSerialLibrary : IDispatch
{

    // Methods
    SAFEARRAY(${IVirtualSerialDevice}) ${getPorts}();
    ${IVirtualSerialDevicePtr#IVirtualSerialDevice} ${createDevice}(const _variant_t & portName);
    HRESULT ${addListener}(${IVirtualSerialLibraryListener} * listener);
    HRESULT ${removeListener}(${IVirtualSerialLibraryListener} * listener);
};

IVirtualSerialLibrary Methods

getPorts

// This method is not available in scripting environment
Array getPorts();
SAFEARRAY(${IVirtualSerialDevice}) getPorts();

Returns an array of all currently configured virtual serial port objects.

getPortsJs

getPortsJs(): ${IVirtualSerialDevice}[];
// This method is not available in managed environment
// This method is not available in native environment

Returns an array of all currently configured virtual serial port objects.

createDevice

createDevice(portName?: string | number): ${IVirtualSerialDevice};
${IVirtualSerialDevice} createDevice(object portName);
${IVirtualSerialDevicePtr#IVirtualSerialDevice} createDevice(const _variant_t & portName);
portName
Port number or a string in the form "COMn". If the requested port is taken, an error code is returned. If omitted, a next available port will be selected automatically.

This method creates new unconnected virtual serial device. This device should be later connected to one of the transports in order to be used.

When last reference to the device is released, the device is not deleted. To delete a device, call IVirtualSerialDevice.deleteDevice method and then release a reference.

The calling application must have required privileges in order to be able to create a device instance on the target computer for this method to work successfully. Otherwise, the “Access Denied” error is returned. When UAC is turned on, the calling application must have already elevated itself before calling this method.

It is allowed to call this method from 32-bit application on 64-bit operating system. In this case, the library uses a proxy to perform device creation in the context of 64-bit process. This is performed transparently for the calling application. The same security and elevation requirements apply in this case.

Native only: This method returns S_OK if device has been successfully created, S_FALSE if device has been created, but restart is required to complete installation. Otherwise, standard COM error code is returned.

addListener

// This method is not available in scripting environment
void addListener(${IVirtualSerialLibraryListener} listener);
HRESULT addListener(${IVirtualSerialLibraryListener} * listener);
listener
A reference to the listener object.

Adds new listener object to the library.

removeListener

// This method is not available in scripting environment
void removeListener(${IVirtualSerialLibraryListener} listener);
HRESULT removeListener(${IVirtualSerialLibraryListener} * listener);
listener
A reference to the listener object.

Removes an object from the library.