调用dll结束时出错

powerhome 2004-07-20 02:29:44
void CTestDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
typedef /*CDialog* */(WINAPI * MAPDLL)(/*CDialog* pDlg,*/ CString sText/*, CWnd* wnd=NULL*/);
HINSTANCE hmod;
hmod = ::LoadLibrary ("MapDll.dll");
if(hmod==NULL)
{
AfxMessageBox("Failed to load dll file!");
}
MAPDLL lpproc;
lpproc = (MAPDLL)GetProcAddress (hmod,"ShowMap");

CString sText = "This is a test!";
if(lpproc!=(MAPDLL)NULL)
/*pDlg2 = */(*lpproc)(/*pDlg, */sText);

FreeLibrary(hmod);

OnOK();
}

在函数结束的时候会弹出一个对话框。

Run-Time Check Failure #0 - 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.
...全文
165 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
footway 2004-07-20
  • 打赏
  • 举报
回复
你给ShowMap传递的参数与ShowMap本身的参数可以不一致。
liotion 2004-07-20
  • 打赏
  • 举报
回复
lpproc(sText);

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧