Delphi使用VC的DLL,如何才能用stdcall的方式?(50分)

B

bokei

Unregistered / Unconfirmed
GUEST, unregistred user!
在WIN2000(p) SP1,Delphi5.0+sp1,vc 6.0 +sp4下
Delphi:
function Test(a1,b1:Integer):Integer;cdecl;external 'F:/TestCode/DLL/Release/dll.dll';
VC:
//头文件
extern "C"
{
DllExport int Test(int a1,int b1);
}
//源文件
DllExport int Test(int a1,int b1)
{
return a1*10+b1;
}
时一切正常.
但是当变成如下情况:
Delphi:
function Test(a1,b1:Integer):Integer;stdcall;external 'F:/TestCode/DLL/Release/dll.dll';
VC:
//头文件
extern "C"
{
DllExport int __stdcall Test(int a1,int b1);
}
//源文件
DllExport int __stdcall Test(int a1,int b1)
{
return a1*10+b1;
}
提示无法定位输入点Test,为什么??怎样才能使用stdcall的方式,而不是cdecl
 
我也遇到一样的问题,可能是两个公司不兼容引起的bug
 
不是兼容问题,仍然是接口定义问题
Delphi中Windows.pas对WinApi的调用都是使用stdcall,而那些DLL都是MS公司的
我以前用VC做过DLL(刚学的时候),好像是用了WINAPI定义了输出函数
VC下有标准的DLL的DEMO,你可以参考,也可以参考VC中的.H文件,看看函数是如何定义的
 
XXX.def文件
EXPORTS
addtest @1
XXX.cpp文件:
int APIENTRY addtest(int a,int b)
{
return a+b;
}

DELPHI中用:
function addtest(a:integer;b:integer):Integer;
stdcall;external 'add.dll';
我测试过,没有问题.
 
int __declspec(dllexport) _stdcall Test(int a1,int b1)
{
return a1*10+b1;
}
 
接受答案了.
 

Similar threads

D
回复
0
查看
1K
DelphiTeacher的专栏
D
I
回复
0
查看
803
import
I
I
回复
0
查看
677
import
I
I
回复
0
查看
599
import
I
顶部