int WriteComm(idComDev, lpvBuf, cbWrite) | |||||
int idComDev; | /* identifier of comm. device | */ | |||
const void FAR* lpvBuf; | /* address of data buffer | */ | |||
int cbWrite; | /* number of bytes to write | */ |
The WriteComm function writes to the specified communications device.
idComDev
Specifies the device to receive the bytes. The OpenComm function returns this value.
lpvBuf
Points to the buffer that contains the bytes to be written.
cbWrite
Specifies the number of bytes to be written.
The return value specifies the number of bytes written, if the function is successful. The return value is less than zero if an error occurs, making the absolute value of the return value the number of bytes written.
To determine what caused an error, use the GetCommError function to retrieve the error value and status.
For serial ports, the WriteComm function deletes data in the transmission queue if there is not enough room in the queue for the additional bytes. Before calling WriteComm, applications should check the available space in the transmission queue by using the GetCommError function. Also, applications should use the OpenComm function to set the size of the transmission queue to an amount no smaller than the size of the largest expected output string.