Date: 02-16-2022
Return to Index
created by gbSnippets
'Author Jose
' ========================================================================================
' The Filter Graph Manager supports the IFilterGraph.EnumFilters method, which enumerates
' all the filters in the filter graph. It returns a pointer to the IEnumFilters interface.
' The IEnumFilters.Next method retrieves IBaseFilter interface pointers.
' ========================================================================================
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
#include "win32api.inc"
#Include Once "dshow.inc"
#Include Once "ole2utils.inc" ' For IUnknown_Release
GLobal FilterList$
Function PBMain
Local pGraph As IGraphBuilder
Local wszFile As WStringZ * %Max_Path
pGraph = NewCom ClsId $CLSID_FilterGraph
wszFile = Exe.Path$ & "alarm.wav"
pGraph.RenderFile(wszFile)
EnumFilters(pGraph)
pGraph = Nothing
? FilterList$
End Function
Function EnumFilters (ByVal pGraph As IGraphBuilder) As Long
Local hr As Long ' HRESULT
Local pEnum As IEnumFilters ' IEnumFilters interface
Local pFilter As IBaseFilter ' IBaseFilter interface
Local cFetched As Dword ' Number of filters fetched
Local FilterInfo As FILTER_INFO ' FILTER_INFO structure
hr = pGraph.EnumFilters(pEnum)
If hr <> %S_Ok Then
Function = hr
Exit Function
End If
Do
hr = pEnum.Next(1, pFilter, cFetched)
If hr <> %S_Ok Or cFetched = 0 Then Exit Do
Reset FilterInfo
hr = pFilter.QueryFilterInfo(FilterInfo)
If hr <> %S_Ok Then
FilterList$ = "Could not get the filter info"
Else
FilterList$ += FilterInfo.achName + $Crlf
' The FILTER_INFO structure holds a pointer to the Filter Graph
' Manager, with a reference count that must be released.
If FilterInfo.pGraph <> %NULL Then IUnknown_Release FilterInfo.pGraph
End If
' Release the filter
pFilter = Nothing
Loop
' Release the collection
pEnum = Nothing
Function = %S_Ok
End Function
http://www.garybeene.com/sw/gbsnippets.htm