[in] Single character to send to the device.
Write
Sends data to a device.
Syntax
Section titled “Syntax”virtual HRESULT Write(char ch, bool bFlush = true, long lTimeout = CUR_TIMEOUT) abstract;
virtual HRESULT Write(BYTE* pBuf, long cbDesired, long* pcbActual = NULL, bool bFlush = true, long lTimeout = CUR_TIMEOUT) abstract;
virtual HRESULT Write(SAFEARRAY* psaBuf, long cbDesired = -1, long* pcbActual = NULL, bool bFlush = true, long lTimeout = CUR_TIMEOUT) abstract;Parameters
Section titled “Parameters”ch
pBuf
[in] Array of bytes to send to the device.
psaBuf
[in] SAFEARRAY of bytes to send to the device. if cbDesired is -1, all elements of the SAFEARRAY are sent.
cbDesired
[in] Number of elements (bytes) to send to the device. If set to -1 and the input is a SAFEARRAY, then all elements of the SAFEARRAY are sent.
pcbActual
[out] Actual number of elements (bytes) sent to the device.
bFlush
[in] If true, the formatted I/O write buffer is flushed to the device.
lTimeout
[in] I/O timeout value in milliseconds.
Return value
Section titled “Return value”Returns S_OK if successful, otherwise a failure HRESULT.
Remarks
Section titled “Remarks”The Write function sends raw bytes to the formatted I/O write buffer. If the bFlush parameter is true, then the contents of the I/O write buffer are flushed to the device. If bFlush is false, then the data is queued in the write buffer until the buffer is full or a subsequent operation forces a flush. Queueing data in this fashion can improve I/O performance by reducing the number of I/O roundtrips to the device.
Example
Section titled “Example”The following example demonstrates use of the Write function.
STDMETHODIMP Acme4321::IAcme4321_Configure(BYTE chData, SAFEARRAY* psaData){ HRESULT hr = S_OK;
// Queue up individual characters in the write buffer hr = io.Write('A', false); hr = io.Write('B', false); hr = io.Write(chData, false);
// Send array of bytes and flush buffer to device hr = io.Write(psaData);
return hr;}