DLL函数动态加载调用后出现 Debug Error! 提示 The value of ESP was not properly saved across a function call.
我用VC调用 VC编写的动态连接库,
原函数声明方式是:
extern "C" __declspec(dllexport) bool CreateDataTable(SDBSrvPara *pSrvPara);
函数实现
__declspec(dllexport) bool CreateDataTable(SDBSrvPara *pSrvPara)
{
return true;
}
在另外一个程序用 LoadLibrary 动态加载这个DLL,
加载调用的声明格式是
typedef bool (CALLBACK * PROC_CreatePlugInDataTable)(SDBSrvPara *);
SDBSrvPara m_dbSrvPara; //是基本结构体(成员是 char,int基本类型的组合)
HMODULE hDeviceDll;
hDeviceDll = ::LoadLibrary(it->second.c_str()); //加载DLL
if( hDeviceDll != NULL)
{
PROC_CreatePlugInDataTable CreateDataTable =
(PROC_CreatePlugInDataTable)::GetProcAddress(hDeviceDll, "CreateDataTable");
if(CreateDataTable != NULL)
{
bool bResutl = CreateDataTable(&m_dbSrvPara);
}
::FreeLibrary(hDeviceDll); //卸载DLL
}
运行到CreateDataTable返回是出现下面的对话框内容.
Debug Error!
Program: F:\Test_Srv.exe
Module:
File: i386\chkesp.c
Line:42
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 funtion pointer declared with a different calling convention.
麻烦大家帮忙看看,谢谢 ̄ ̄