Hi.
Can you help me to solve this issue.... Im working with DirectShow and
Windows Media Format SDKs from a C# app so there is a lot of interop library
work (http://directshownet.sourceforge.net), this access to directshow is
great but there is a task i want to do that requires me to use the COM
IServiceProvider interface - this is not part of the metioned library so i
would love it anyone could tell me how to make this interface available to
managed code....
This is a snippet of what i do in C++ code that i what to do in C#;
IBaseFilter pASFWriter = [instantiate this object..........]
IWMWriterAdvanced2 *pWMWA2 = NULL;
IServiceProvider *pProvider = NULL;
pASFWriter->QueryInterface(IID_IServiceProvider, (void**)&pProvider);
pProvider->QueryService(IID_IWMWriterAdvanced2, IID_IWMWriterAdvanced2,
(void**)&pWMWA2);
pWMWA2->AddSink(....);
the important part is the IServiceProvider::QueryService method. In
servprov.h this is declared as;
EXTERN_C const IID IID_IServiceProvider;
extern "C++"
{
MIDL_INTERFACE("6d5140c1-7436-11ce-8034-00aa006009fa")
IServiceProvider : public IUnknown
{
public:
virtual /* [local] */ HRESULT STDMETHODCALLTYPE QueryService(
/* [in] */ REFGUID guidService,
/* [in] */ REFIID riid,
/* [out] */ void __RPC_FAR *__RPC_FAR *ppvObject) = 0;
template <class Q>
HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, Q**
pp)
{
return QueryService(guidService, __uuidof(Q), (void **)pp);
}
};
}
so in C# i need to declare the interface, but as what?
[Guid("6d5140c1-7436-11ce-8034-00aa006009fa"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IServiceProvider
{
//QueryService(...)
}
I am really struggling to understand how to map over the interface so any
help would be most appreciated, many thank.

Signature
Ben
LGS - 01 Sep 2005 23:45 GMT
I did this with .NET's built-in IServiceProvider.
If it helps, I have done a (very) rough translation of the IWM* interfaces.
It is largely untested, but you are welcome to it. Currently you can find it
here: http://www.LimeGreenSocks.com/DShow/w.zip. In the next few days I plan
to move it over to be next to the DirectShow library at
http://DirectShowNet.SourceForge.net
In the AsfNet sample, I do just what you are describing here.
I would appreciate any feedback you have on this library before I release it.
> there is a task i want to do that requires me to use the COM
> IServiceProvider interface