IMFAttributes::GetItemByIndex method (mfobjects.h)

Retrieves an attribute at the specified index.


HRESULT GetItemByIndex(
  [in]      UINT32      unIndex,
  [out]     GUID        *pguidKey,
  [in, out] PROPVARIANT *pValue


[in] unIndex

Index of the attribute to retrieve. To get the number of attributes, call IMFAttributes::GetCount.

[out] pguidKey

Receives the GUID that identifies this attribute.

[in, out] pValue

Pointer to a PROPVARIANT that receives the value. This parameter can be NULL. If it is not NULL, the method fills the PROPVARIANT with a copy of the attribute value. Call PropVariantClear to free the memory allocated by this method.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
The method succeeded.
Invalid index.


To enumerate all of an object's attributes in a thread-safe way, do the following:

  1. Call IMFAttributes::LockStore to prevent another thread from adding or deleting attributes.
  2. Call IMFAttributes::GetCount to find the number of attributes.
  3. Call GetItemByIndex to get each attribute by index.
  4. Call IMFAttributes::UnlockStore to unlock the attribute store.
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.


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

Attributes and Properties