int WriteComm(nCid,lpBuf,nSize)
This function writes the number of characters specified by the nSize parameter to the communication device specified by the nCid parameter from the buffer pointed to by the lpBuf parameter.
Parameter | Type/Description |
nCid | int Specifies the device to receive the characters. The OpenComm function returns this value. | |
lpBuf | LPSTR Points to the buffer that contains the characters to be written. | |
nSize | int Specifies the number of characters to write. |
The return value specifies the number of characters actually written. When an error occurs, the return value is set to a value less than zero, making the absolute value of the return value the actual number of characters written. The cause of the error can be determined by using the GetCommError function to retrieve the error code and status.
The WriteComm function will delete data in the transmit queue if there is not enough room in the queue for the additional characters. Applications should check the available space in the transmit queue with the GetCommError function before calling WriteComm. Also, applications should use the OpenComm function to set the size of the transmit queue to an amount no smaller than the size of the largest expected output string.