Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2005

Tip: Looking for answers? Try searching our database.

COM Interop: map IServiceProvider interface to managed code.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ben Whittle - 01 Sep 2005 18:19 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.