IMFByteStream::BeginRead method (mfobjects.h)

Begins an asynchronous read operation from the stream.


HRESULT BeginRead(
  [in] BYTE             *pb,
  [in] ULONG            cb,
  [in] IMFAsyncCallback *pCallback,
  [in] IUnknown         *punkState


[in] pb

Pointer to a buffer that receives the data. The caller must allocate the buffer.

[in] cb

Size of the buffer in bytes.

[in] pCallback

Pointer to the IMFAsyncCallback interface of a callback object. The caller must implement this interface.

[in] punkState

Pointer to the IUnknown interface of a state object, defined by the caller. This parameter can be NULL. You can use this object to hold state information. The object is returned to the caller when the callback is invoked.

Return value

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


When all of the data has been read into the buffer, the callback object's IMFAsyncCallback::Invoke method is called. At that point, the application should call IMFByteStream::EndRead to complete the asynchronous request.

Do not read from, write to, free, or reallocate the buffer while an asynchronous read is pending.

Implementation notes:This method should update the current position in the stream by adding the number of bytes that will be read, which is specified by the value returned in the pcbRead parameter, to the current position. Other methods that can update the current position are BeginRead, Write, BeginWrite, Seek, and SetCurrentPosition.

This interface is available on the following platforms if the Windows Media Format 11 SDK redistributable components are installed:

  • Windows XP with Service Pack 2 (SP2) and later.
  • Windows XP Media Center Edition 2005 with KB900325 (Windows XP Media Center Edition 2005) and KB925766 (October 2006 Update Rollup for Windows XP Media Center Edition) installed.


Requirement Value
Minimum supported client Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header mfobjects.h (include Mfidl.h)
Library Mfuuid.lib

See also