I am using a DirectShowLib which is a thin wrapper for DirectShow. I have successfully enumerated BDA devices and collected their CLSIDs. Now when user selects a device by name and I know the chosen CLSID, I need to add this device to my filter graph.
I did the following:
Type type = Type.GetTypeFromCLSID(classid);
object device = Activator.CreateInstance(type);
Now the question is - what kind of object I got here in device? Debugger shows that it is a valid Com object. If I try to cast it to IBaseFilter, I get an exception "No such interface supported". I can cast it to IMoniker successfully. But then if I try to do the following:
int hr = graphBuilder.AddSourceFilterForMoniker(
device, null, filtername, out receivedFilter);
I get an error:
HRESULT: 0x800401e4 (2147746276)
Name: MK_E_SYNTAX
I know that the method AddSourceFilterForMoniker works fine if I use it right after enumeration, so it seems I just do not create the moniker right.
What is the right way to create moniker object if class id is known, so I can pass it to the AddSourceFilterForMoniker?