Tech Off Post

Single Post Permalink

View Thread: Writing a managed version of ICreateDevEnum
  • User profile image

    I have the following interface from "strmif.h" (DirectShow stuff):

        ICreateDevEnum : public IUnknown
            virtual HRESULT STDMETHODCALLTYPE CreateClassEnumerator(
                /* [in] */ REFCLSID clsidDeviceClass,
                /* [out] */ IEnumMoniker **ppEnumMoniker,
                /* [in] */ DWORD dwFlags) = 0;

    I have found it described in C# like this (in a project called DShow.NET):

        [ComVisible(true), ComImport,
        InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
    public interface ICreateDevEnum
        int CreateClassEnumerator(
            [In]                                            ref Guid            pType,
            [Out]                                        out UCOMIEnumMoniker    ppEnumMoniker,
            [In]                                            int                    dwFlags );

    The generated MSIL for the function is:

    .method public hidebysig newslot abstract virtual
            instance int32  CreateClassEnumerator([in] valuetype [mscorlib]System.Guid& pType,
                                                  [out] class [mscorlib]System.Runtime.InteropServices.UCOMIEnumMoniker& ppEnumMoniker,
                                                  [in] int32 dwFlags) cil managed preservesig
    } // end of method ICreateDevEnum::CreateClassEnumerator

    And now my question is: How to represent this interface in C++/CLI? I use VS2005, and tried several times, but it doesn't compile. I am stuck on the IEnumMoniker parameter, don't know how to declare it.

    Does anyone have an idea on how to write this interface in C++/CLI, so that I am able to cast the COM server 'SystemDeviceEnum' to the interface 'ICreateDevEnum'?