[in] String data to send to the device.
WriteString
Sends data to a device.
Syntax
Section titled “Syntax”virtual HRESULT WriteString(const CString& strData, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteString(BSTR strData, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;
virtual HRESULT WriteString(LPCTSTR strData, bool bFlush = true, long lTimeout = CUR_TIMEOUT) override;Parameters
Section titled “Parameters”strData
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 WriteString function sends string data 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 WriteString function.
STDMETHODIMP Acme4321::IAcme4321_Configure(BSTR bstrSource1, BSTR bstrSource2, BSTR bstrSource3){ HRESULT hr = S_OK;
// Queue up commands in the write buffer hr = io.WriteStringNoPoll(bstrSource1, false); hr = io.WriteStringNoPoll(bstrSource2, false);
// Send string and flush buffer to device hr = io.WriteString(bstrSource3);
return hr;}