ComOpen Procedure

Opens a COM port for I/O.

Syntax

[ lStatus = ] ComOpen ( lPort )

The ComOpen procedure syntax has the following parts:

 

Name

Type

Description

lStatus

Long

Status, -1 on failure, 0 on success

lPort

Val Long

Serial port number (1 for COM1, etc.)

Comments

COM ports are opened with shared access allowing more than one process to read/write to the port. If you need to check if a port is open prior to calling this function, you can use the FileOpen with "\\\\.\\COMx" where x is the port number.

The possible range of the lPort is limited by the number of ports supported by the Windows serial communication driver.

Example

The following example opens the COM12 port for asynchronous data transfer:

ComOpen(12)

See Also

ComClose, ComSetup