Opens a COM port for I/O.
[ 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.) |
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.
The following example opens the COM12 port for asynchronous data transfer:
ComOpen(12)