1

I have a custom DirectShow filter created by extending the ezrgb24 filter from the DirectShow sample documentation.

I am using this filter (indirectly) in C# through a 3rd party multimedia SDK (LeadTools). Now I need to add a reference to the filter's DLL to the project so that I can cast an IUnknown interface retrieved by the SDK to the filter's own custom interface.

I have tried adding the DLL reference through add reference -> browse, and by using tlbimp directly at the commandline. Both approaches result in the error 'C:\windows\system32\ezrgb24.dll' is not a valid type library.

Am I missing something? The extensions I have made to the ezrgb24 example are pretty trivial structurally, essentially if anyone has the DirectShow examples they know exactly the code I am working with.

Any and all help is greatly appreciated.

Tony.

asked May 10, 2010 at 13:47

2 Answers 2

2

You need to write interface in C# and use ComImport attribute. For example sample filter from SDK will look

[ComImport,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown), 
Guid("fd5010a3-8ebe-11ce-8183-00aa00577da1")] //guid defined for interface in example code
public interface IIPEffect
{
 [PreserveSig]
 int get_IPEffect(out int effectTime, out double startTime, out double length);
 [PreserveSig]
 int set_IPEffect(int effectNum, double startTime, double length);
}

Now you can use interface definition is such way

//find IBaseFilter somehow
var effectFilter = FindFilter() as IIPEffect;
effectFilter.set_IPEffect(0, 0, 20);

NOTE: in interface definition there is REFTIME type as parameter for length and startTime, but it is simple typedef and that's why in our code it is double. For more information on converting interface definition to C# you can read marshaling article on msdn

answered May 11, 2010 at 9:43
Sign up to request clarification or add additional context in comments.

3 Comments

thank you, this method has worked brilliantly for my purposes.
will you expect this to work if the dll is registered only using regsvr32? Because I trying to call set_IPEffect and it throws an exception to me. Sorry to did this old answer but I need an advice
Yes, it should work. What kind of exception is thrown?
1

The standard DirectShow filter samples do not implement IDispatch compatible interfaces. Furthermore, there are no type libraries in these dlls. You have to implement your own type library interface.

You can use ATL to do this.

answered May 10, 2010 at 15:42

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.