How can I use a "native" pointer in a reference class in C ++ / CLI?

I am trying to write a small library that will use DirectShow. This library should be used by the .NET application, so I thought it was best to write it in C ++ / CLI.

I am having problems with this line:

    HRESULT hr = CoCreateInstance(  CLSID_FilterGraph,
                                    NULL,
                                    CLSCTX_INPROC_SERVER,
                                    IID_IGraphBuilder,
                                    (void**)(&graphBuilder) );  //error C2440:

Where graphBuilderannounced:

public ref class VideoPlayer
{
public:
    VideoPlayer();
    void Load(String^ filename);

    IGraphBuilder*  graphBuilder;

};

If I understand this page correctly , I can use it */&, as usual, to indicate "native" pointers to unmanaged memory in my C ++ / CLI Library; ^used to indicate a pointer to a managed entity. However, this code creates:

error C2440: 'type cast': cannot convert from 'cli :: interior_ptr' to 'void **'

, graphBuilder 'cli::interior_ptr<Type>'. / , ? . , - ). , , graphBuilder "" ?

( , , pin_ptr, , )

+5
1

, , . , , , . gc .

, . . :

void init() {
    IGraphBuilder* builder;    // Local variable, okay to pass its address
    HRESULT hr = CoCreateInstance(CLSID_FilterGraph,
        NULL,
        CLSCTX_INPROC_SERVER,
        IID_IGraphBuilder,
        (void**)(&builder) );
    if (SUCCEEDED(hr)) {
        graphBuilder = builder;
        // etc...
    }
}
+9

All Articles