Freigeben über


IMFCollection::GetElement Method

Retrieves an object in the collection.

Syntax

HRESULT GetElement(
  [in]   DWORD dwElementIndex,
  [out]  IUnknown **ppUnkElement
);

Parameter

  • dwElementIndex [in]
    Zero-based index of the object to retrieve. Objects are indexed in the order in which they were added to the collection.

  • ppUnkElement [out]
    Receives a pointer to the object's IUnknown interface. The caller must release the interface. The retrieved pointer value might be NULL.

Rückgabewert

Ist Methode erfolgreich, wird "S_OK" zurückgegeben. Andernfalls wird ein HRESULT-Fehlercode zurückgegeben.

Hinweise

This method does not remove the object from the collection. To remove an object, call IMFCollection::RemoveElement.

Beispiele

//  Gets an interface pointer from a collection (IMFCollection).
//
//  Q: Interface type

template <class Q>
HRESULT GetCollectionObject(IMFCollection *pCollection, 
    DWORD dwIndex, Q **ppObject)
{
    *ppObject = NULL;   // zero output

    IUnknown *pUnk = NULL;
    HRESULT hr = pCollection->GetElement(dwIndex, &pUnk);
    if (SUCCEEDED(hr))
    {
        hr = pUnk->QueryInterface(IID_PPV_ARGS(ppObject));
        pUnk->Release();
    }
    return hr;
}

Anforderungen

Mindestens unterstützter Client

Windows Vista

Mindestens unterstützter Server

Windows Server 2008

Header

Mfobjects.h (include Mfidl.h)

Bibliothek

Mfuuid.lib

Siehe auch

IMFCollection