Interface method calling convention

  • Thread starter Thread starter Builder
  • Start date Start date
B

Builder

Hi,

I imported following COM interface

DECLARE_INTERFACE(IAxMediaCB)
{

STDMETHOD(BufferCB)
(
LONGLONG theStartTime,
BYTE * theDstBuffer,
long theSize
) PURE;
};


to managed code:

public interface IAxMediaCB
{
int BufferCB(long theStartTime, IntPtr theDstBuffer, int
theSize);
}

Is there any way to declare in .NET that interface method BufferCB has
a __cdecl calling convention? I know there is
UnmanagedFunctionPointerAttribute, but this can be only applied on
the delegate. I need somethig similar, but destination should be a
method. Is there any way to do it?
 
Hi,

I imported following COM interface

DECLARE_INTERFACE(IAxMediaCB)
{

  STDMETHOD(BufferCB)
    (
    LONGLONG  theStartTime,
    BYTE * theDstBuffer,
    long  theSize
    ) PURE;

};

to managed code:

    public interface IAxMediaCB
    {
        int BufferCB(long theStartTime, IntPtr theDstBuffer, int
theSize);
    }

Is there any way to declare in .NET that interface method BufferCB has
a __cdecl calling convention?

Actually, given your C declaration, the method is not cdecl; it's
stdcall. Which means that .NET COM interop should just work. You will
still need MethodImplAttribute on method declarations, though - import
some random COM component into your .NET application, and look at the
generated assembly in ildasm to see what it would look like.
 
You will
still need MethodImplAttribute on method declarations, though - import
some random COM component into your .NET application, and look at the
generated assembly in ildasm to see what it would look like.

That's not necessary, but he will need to add the ComImport, Guid and
InterfaceType attributes to the interface itself.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top