我这里有个需要用cdecl方法来呼叫的DLL,但.net中用C#写的方法默认都是stdcall方式。如何在程序中指定用cdecl方式来呼叫呢?
我在网上搜索后发先大多用:
[DllImport("msvcrt.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
来处理,但VS 2008 CallingConvention只有CallingConvention.winapi,他只有在Windows CE上才默认用cdecl来呼叫,其他时候用stdcall方式。我怎样才能够在Windows环境中指定用cdecl方式呢?
我在网上搜索后发先大多用:
[DllImport("msvcrt.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
来处理,但VS 2008 CallingConvention只有CallingConvention.winapi,他只有在Windows CE上才默认用cdecl来呼叫,其他时候用stdcall方式。我怎样才能够在Windows环境中指定用cdecl方式呢?
[DllImport("xxx.dll", EntryPoint = "test",CallingConvention=CallingConvention.Cdecl)]
public partial class MainForm : Form {
[DllImport("SSSS.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]但编译会出现:
错误 1 “System.Runtime.InteropServices.CallingConvention”并不包含“Cdecl”的定义 E:\Windows Mobile\TestCode\MobileTest\MobileTest\MainForm.cs 14 100 MobileTest请大家帮忙看下,谢谢了
我在Windows开发环境中试过
DllImport("SSSS.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
是可以编译通过的,但在Mobile环境中就会出现上面的问题。
那在.NET Compact Framework 3.5上如何运用Cdecl方式调用DLL方法呢?