473,394 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Interface method calling convention

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
2 2393
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
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Lenard Lindstrom | last post by:
I was wondering if anyone has suggested having Python determine a method's kind from its first parameter. 'self' is a de facto reserved word; 'cls' is a good indicator of a class method ( __new__...
1
by: Asapi | last post by:
1. Are linkage convention and calling convention referring to the same thing? 2. Does calling convention differ between languages C and C++? 3. How does calling convention differ between...
8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
20
by: Ole Hanson | last post by:
I am accessing my database through an interface, to allow future substitution of the physical datastore - hence I would like to declare in my Interface that my DAL-objects implementing the...
16
by: Daniel Mori | last post by:
If an object implements the IDisposable interface (regardless if its a framework object or a user object), should I always dispose of that object out of principle?
6
by: ~~~ .NET Ed ~~~ | last post by:
Yes, I think so at least... In C# you *can* have static properties which are quite useful when used properly. Now imagine the scenario where you need the ability (sp?) to implement a variety of...
1
by: noony | last post by:
Here is the error I get after calling a method (described below) : Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling...
10
by: sulekhasweety | last post by:
Hi, the following is the definition for calling convention ,which I have seen in a text book, can anyone give a more detailed explanation in terms of ANSI - C "the requirements that a...
16
by: Jaco Naude | last post by:
Hi there, This is my first post over here and I hope someone can give me some guidance. I'm trying to embed Python into a Visual C++ 2008 application and I'm getting linker problems. I've...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.