FilterGraphTools.AddFilterFromClsid Method

DirectShowLib.Utils

A Managed DirectShow Toolkit

FilterGraphTools.AddFilterFromClsid Method 

Add a filter to a DirectShow Graph using its CLSID

public static IBaseFilter AddFilterFromClsid(
   IGraphBuilder graphBuilder,
   Guid clsid,
   string name
);

Parameters

graphBuilder
the IGraphBuilder interface of the graph
clsid
a valid CLSID. This object must implement IBaseFilter
name
the name used in the graph (may be null)

Return Value

an instance of the filter if the method successfully created it, null if not

Remarks

You can use IsThisComObjectInstalled to check is the CLSID is valid before calling this method

Exceptions

Exception Type Condition
ArgumentNullException Thrown if graphBuilder is null
COMException Thrown if errors occur when the filter is add to the graph

Example

This sample shows how to programmatically add a NVIDIA Video decoder filter to a graph

Guid nvidiaVideoDecClsid = new Guid("71E4616A-DB5E-452B-8CA5-71D9CC7805E9");

if (FilterGraphTools.IsThisComObjectInstalled(nvidiaVideoDecClsid))
{
  filter = FilterGraphTools.AddFilterFromClsid(graphBuilder, nvidiaVideoDecClsid, "NVIDIA Video Decoder");
}
else
{
  // use another filter...
}

See Also

FilterGraphTools Class | DirectShowLib.Utils Namespace | IsThisComObjectInstalled