vc++写的dll在delphi中的调用(50分)

S

solley

Unregistered / Unconfirmed
GUEST, unregistred user!
我用vc++中写的一个简单的dll,但在delphi中调用时总是出现找不到入口点的错误,
我用delphi写了相同的dll,调用时就没有任何问题。

函数声明为:
function add (x:integer;y:integer):integer;stdcall;external 'math.dll'

调用为:

Total := add(a,b)

为什么?
 
在VC中也要声明为 __stdcall 或 cdecl
 
这是DELPHI中函数的声明(这几种声明形式我都用过了):
//function addition(x:real;y:real):real;stdcall;external 'testdll.dll' name 'firstdll'
function add(x:integer;y:integer):integer;stdcall;external 'math.dll'
//function add (x:integer;y:integer):integer;cdecl;external 'math.dll'
//function add (x:integer;y:integer):integer;safecall;external 'math.dll'

这是VC中函数的定义:
MATH_API int _stdcall add(int x, int y)
{
int z = x + y ;

return z ;

}
 
去掉stdcall
 
MATH_API 这个可以不要!
你的 __stdcall 是几个下划线。
 
一个、两个下化线都试过了。
 
修改一下VC工程中的.def文件:
----------------------------------
; DLL_Test1.def : Declares the module parameters for the DLL.

LIBRARY "DLL_Test1"
DESCRIPTION 'DLL_Test1 Windows Dynamic Link Library'

EXPORTS
add @1; Explicit exports can go here
 
顶部