显示调用第三方DLL,出现这样的错误
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 declared with a different calling convention.
源代码如下
int CFybjCtrl::OCXinit_port(LPCTSTR str)
{
typedef HANDLE(_stdcall *lpAddFun)(char *portname); //宏定义函数指针类型
lpAddFun addFun;//函数指针
hDll = LoadLibrary("..//Multi.dll");//加载DLL
if (hDll != NULL)
{
addFun = (lpAddFun)GetProcAddress(hDll, "init_port");
if (addFun != NULL)
{
hand = addFun((char *)str);//根据接口定入传参、返回
//printf("%d", result);
}
FreeLibrary(hDll);
}
if(hand==NULL || hand<0)
{
//AfxMessageBox("串口1连接失败!");
return -1;
}
else //the comm port open successfully
{
//AfxMessageBox("串口1打开成功!");
return 1;
}
}