IEnumMediaTypes::Next method (strmif.h)

[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The Next method retrieves a specified number of media types.


  [in]  ULONG         cMediaTypes,
  [out] AM_MEDIA_TYPE **ppMediaTypes,
  [out] ULONG         *pcFetched


[in] cMediaTypes

The number of media types to retrieve.

[out] ppMediaTypes

The address of an array of AM_MEDIA_TYPE pointers. The number of elements in the array is given in the cMediaTypes parameter.

[out] pcFetched

Receives the number of media types returned in ppMediaTypes. This parameter can be NULL if cMediaTypes is 1.

Return value

Returns one of the following HRESULT values.

Return code Description
Did not retrieve as many media types as requested.
Invalid argument.
NULL pointer argument.
The pin's state has changed and is now inconsistent with the enumerator.


The caller passes an array of AM_MEDIA_TYPE pointers in ppMediaTypes. The method allocates a number AM_MEDIA_TYPE structures equal to cMediaTypes or to the number of media types that remain in the enumeration, whichever is less. The number of structures allocated is returned in pcFetched. Delete each structure by calling the DeleteMediaType function.

If the set of media types changes, the enumerator becomes inconsistent with the owning pin. In that case, the method returns VFW_E_ENUM_OUT_OF_SYNC. Discard any data obtained from previous calls to the enumerator, because it might be invalid. Update the enumerator by calling the IEnumMediaTypes::Reset method. You can then call the Next method safely.


Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header strmif.h (include Dshow.h)
Library Strmiids.lib

See also

Enumerating Media Types

Error and Success Codes

IEnumMediaTypes Interface