Click or drag to resize

LowLevelWriteString

Writes raw bytes directly to a device without going through the formatted I/O write buffer.

virtual HRESULT LowLevelWriteString(const CString& strBuf, long* pcchActual = NULL, bool bAddTrailing = true, long lTimeout = CUR_TIMEOUT)  override;	

virtual HRESULT LowLevelWriteString(BSTR strBuf, long* pcchActual = NULL, bool bAddTrailing = true, long lTimeout = CUR_TIMEOUT) override;	
Parameters
strBuf

[int] Array of characters to be written to the device.

pcchActual

[out] Actual number of bytes written to the device. pcchActual may be set to NULL if the caller is not interested in knowing the actual number of bytes written.

bAddTrailing

[in] true to have the trailing characters specified by the SetTrailingForWrites function automatically added to strBuf before sending to the device.

lTimeout

[in] I/O timeout value in milliseconds.

Return Value

Returns S_OK if successful, otherwise a failure HRESULT.

Remarks

Unlike the buffered I/O functions, such as Printf, Write and WriteNumber, etc., the LowLevelWriteString function sends raw bytes directly to the device, rather than going through formatted I/O write buffer.

Each character in strBuf is converted to ASCII and sent to the device. An error is returned if one or more of the Unicode characters in strBuf cannot be converted to ASCII.

Caution note Caution

It is critical that these low-level functions not be intermixed with buffered I/O functions in a sequence of operations, such as a set of calls implementing a single driver method. The buffered I/O functions assume that all data read from or sent to the device passes through the I/O buffer, and intermixing these calls with low-level functions that directly access the device can produce incorrect results and/or I/O errors.

Example

The following example demonstrates use of the LowLevelWriteString function.

C++
// CoAcme4321.cpp
STDMETHODIMP Acme4321::IAcme4321_Configure(BSTR bstrData)
{
  HRESULT hr = S_OK;

  hr = io.LowLevel.LowLevelWriteString(bstrData);

  return hr;
}
See Also

Download a complete CHM version of this documentation here.