Click or drag to resize

WriteAsync

Sends data to a device asynchronously.

virtual HRESULT WriteAsync(BYTE* pBuf, long cbDesired, ULONG* plJobId) abstract;

virtual HRESULT WriteAsync(SAFEARRAY** pBuf, long cbDesired, ULONG* plJobId) abstract;
Parameters
pBuf

[in] Data to send to the device.

cbDesired

[in] Number of bytes to send to the device.

plJobId

[in] Asynchronous job identifier for the operation.

Return Value

Returns S_OK if successful, otherwise a failure HRESULT.

Remarks

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

The WriteAsync function returns immediately. An I/O Completion event will be posted when the transfer is actually completed. The plJobId can be used with an I/O Completion event to identify which asynchronous write operation completed.

Example

The following example demonstrates use of the WriteAsync function.

C++
// CoAcme4321.cpp
STDMETHODIMP Acme4321::IAcme4321_Write(SAFEARRAY** ppsaData)
{
  HRESULT hr = S_OK;

  // Start asynchronous write operation 
  long lJobId;
  hr = io.LowLevel.WriteAsync(ppsaData, 1000, &lJobId);

  return hr;
}
See Also

Other Resources

Download a complete CHM version of this documentation here.