|
|
I meet a problem when I call the another MFC DLL's function.
I create two projects.
First project is called maxProjectMFCDLL, which is a MFC DLL project.
maxProjectMFCDLL.def's content as below:
LIBRARY "maxProjectMFCDLL"
EXPORTS
fDoExport @1
maxProjectMFCDLL.cpp's additional content as below:
int fDoExport(int a)
{
MessageBox(NULL,"name","Warn",MB_OK);
return TRUE;
}
Second project is called TestDialog, which is a MFC Dialog project.
I add a button to the dialog and add the function OnBnClickedButton1 for clicking the button.
void CTestDialogDlg::OnBnClickedButton1()
{
typedef int (CALLBACK* D_MYEXPORT)(int);
HMODULE l_mod;
D_MYEXPORT l_export=NULL;
int l_ret=0;
l_mod=LoadLibrary(L"..\\maxProjectMFCDLL.dll");
if (l_mod!=NULL)
{
int a=1;
l_export=(D_MYEXPORT)GetProcAddress(l_mod,"fDoExport");
l_ret=l_export(a);
FreeLibrary(l_mod);
}
}
After I build the Frist and Second projects, run the Second project. VC++ appear a error message(http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/MFC%20DLL.JPG).
The message is "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 callinc convention with a function pointer declared with a different calling convention."
Could somebody tell me how to solve this problem?
I put my complete source code at http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/3ds%20max%20Plugin%20Two%20Project%20Q2.rar |
|