动态链接库调用出错

来源:百度知道 编辑:UC知道 时间:2024/06/07 18:19:28
我用VC++编写了一个画图的动态链接库,编译无误,每次调用时功能也均可以正常实现,但当运行结束返回时总是弹出Microsoft Visual C++ Debug Library对话框,提示Debug Error!
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer decleared with a different calling convention.
(Press Retry to debug the application)
选择“忽略”后程序能够继续正常运行,但每次调用都要弹出这个提示。
请问一下这是怎么回事?怎样能够不弹出这个对话框?
我调用dll的程序是从网上搜的:
typedef void (WINAPI * TESTDLL)(double* l1,double* l2,double* l3,double* l4,double* l5,double* l6,int xn,int xx,int ln,CString message);
HINSTANCE hmod;
hmod = ::LoadLibrary ("mychart.dll");//调用mychart.dll
if(hmod==NULL)
{
AfxMessageBox("Fail");
}
TESTDLL lpproc;
lpproc = (TESTDLL)GetProcAddress (hmod,"disp_chart");
CString msg;
if(lpproc!=(TESTDLL)NULL)
{
msg.Format("");
(*lpproc)(rcerr,NULL,NULL,NULL,

The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer decleared with a different calling convention.
(Press Retry to debug the application)
这段话在线翻译是:价值的电除尘器未有妥善保存跨越函数调用。这通常是因拨打一个功能是宣告一个调用约定与函数指针decleared一种不同的调用约定。
(记者再审调试应用)

不好意思~我能做的就只能是这样,其它的我都不会了~

你调用函数所使用的调用规则和动态库所定义的函数调用规则不一致,导致调用时堆栈操作出错了。位置就是你定义函数时使用的WINAPI,可以把它换成__stdcall或者__cdecl或者__pascal来试试,看哪个可以正常调用。