473,385 Members | 1,341 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,385 software developers and data experts.

DllImport with CallingConvention.StdCall and _cdecl


Hello,

in some old projects I am using DllImport with its default
CallingConvention.StdCall, but the according DLL uses
standard _cdecl calling convention.
To my understanding this should not work, since the
calling convention does not agree - in fact it seems to
work since we did not notice any problems.

Could someone explain what's going on?

Thanks!

Apr 20 '07 #1
1 4999
"Ezmeralda" <ez*******@gmx.dewrote in message
news:11*********************@n76g2000hsh.googlegro ups.com...
>
Hello,

in some old projects I am using DllImport with its default
CallingConvention.StdCall, but the according DLL uses
standard _cdecl calling convention.
To my understanding this should not work, since the
calling convention does not agree - in fact it seems to
work since we did not notice any problems.

Could someone explain what's going on?

Thanks!
The interop layer is able (to a certain extend) to correct calling convention mismatches,
however you better change your code so the caller matches the callee, else you'll incur a
small performance hit. Note that this hack is only for correcting managed to unmanaged
calls, not for unmanaged callbacks.

Willy.


Apr 20 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Gloor | last post by:
Hello NG, I have a mirror.dll written in C I would like to access from a C# console application. However, I dont't know how to to it. The dll is fairly well documented and I have access to the...
1
by: Brian Anderson | last post by:
Hello, I have a native, C++ console app that uses ~26MB of RAM when it runs. It uses quite a lot of RAM to make some math but will never xceed 26MB. Now I've made a dll out of this code and...
1
by: Vagabond Software | last post by:
I am trying to convert a C# .NET wrapper for Microsoft's unmanaged 'cabinet.dll' to Visual Basic .NET and have hit a stumbling block. Here is the C# code that I am trying to convert: private...
4
by: cfennessy | last post by:
I am having problems when I run the following code. I get the error message that the Object reference not set to an instance of the object. Does anyone have any idea what I am doing wrong? I am...
1
by: Areq | last post by:
Hi, Im writting in vc2005 sth like that: extern "C" int __stdcall TestHello(char *file); i get message "'DllImport' : attribute not found" When i add "using namespace...
2
by: =?Utf-8?B?U0FM?= | last post by:
Hello, I am getting the following error: "An attribute argument must be a constant expression, typeof expression or array creation expression" with this line of code on my GetDLLName() that...
2
by: Boki | last post by:
Hi All, I need to use this line ( copy from somewhere to create mouse click event ) However, I can't pass complier, the error message is: =>
1
by: Thomas Due | last post by:
Hi, I manage an rather old application in which we have some fairly complex (ugly) Delphi code. This is Delphi 6 we're talking about. Among all this Delphi code there is method for formating a...
4
by: =?Utf-8?B?TGVvbg==?= | last post by:
Hi, I have a C exported function in a DLL that has the following proto-type: int _cdecl MyFunction( LPCSTR fmt, ... ); Does anyone know the DllImport declaration for this so that I can call...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.