检索集合中的 对象。
语法
HRESULT GetElement(
  [in]  DWORD    dwElementIndex,
  [out] IUnknown **ppUnkElement
);
参数
[in] dwElementIndex
要检索的对象从零开始的索引。 对象按添加到集合中的顺序编制索引。
[out] ppUnkElement
接收指向对象的 IUnknown 接口的指针。 调用方必须释放接口。 检索到的指针值可能为 NULL。
返回值
如果该方法成功,则返回 S_OK。 否则,将返回 HRESULT 错误代码。
注解
此方法不会从集合中删除 对象。 若要删除对象,请调用 IMFCollection::RemoveElement。
示例
//  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;
}
要求
| 要求 | 值 | 
|---|---|
| 最低受支持的客户端 | Windows Vista [桌面应用 | UWP 应用] | 
| 最低受支持的服务器 | Windows Server 2008 [桌面应用 | UWP 应用] | 
| 目标平台 | Windows | 
| 标头 | mfobjects.h (包括 Mfidl.h) | 
| Library | Mfuuid.lib |