首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi写的dll VC中调用报错。该怎么解决

2012-10-23 
delphi写的dll VC中调用报错。delphi中一个很简单的函数:function GetMaxVal(BmpFile: PChar) : Integerbe

delphi写的dll VC中调用报错。
delphi中一个很简单的函数:
function GetMaxVal(BmpFile: PChar) : Integer;
begin
  Result := 10;
end;

vc中:
typedef int(*GetMaxVal)(PCHAR path);

HINSTANCEhandle = LoadLibrary("xxx.dll");

GetMaxVal gv;

gv = (GetMaxVal)GetProcAddress(handle,"GetMaxVal");

char *path = new char[128];
memset(path, 0, 128);
strcpy(path, "c:\\3.bmp");
int kk = gv(path);

出来一个终止,重试,忽略的报错框:
file:i386\chkesp.c
Line:42

The value of esp was not proerly saved across a function all.................


如果把delphi中的函数的PChar参数去掉,就能正常调用。

[解决办法]
GetMaxVal指定为stdcall调用约定了吗
[解决办法]
没看到你代码里的stdcall似的
[解决办法]

探讨
引用:
GetMaxVal指定为stdcall调用约定了吗


指定了。

[解决办法]
100%是这个原因

function GetMaxVal(BmpFile: PChar) : Integer; stdcall;

vc中:
typedef __stdcall int(*GetMaxVal)(PCHAR path);

热点排行