By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,666 Members | 1,784 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,666 IT Pros & Developers. It's quick & easy.

Interface method calling convention

P: n/a
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?
Aug 15 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Aug 15, 11:15*am, Builder <peter.gej...@gmail.comwrote:
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.
Aug 15 '08 #2

P: n/a
>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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Aug 15 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.