void CDll1testDlg::OnButton1()
{
// TODO: Add your control notification handler code here
HINSTANCE hdll=0;
hdll=LoadLibrary("dll1.dll");
char a[1];
typedef int (*addlocal)(int a,int b);
addlocal add=(addlocal)GetProcAddress(hdll,MAKEINTRESOURCE(3));
if (!add)
{
MessageBox("fail!");
return;
}
CString str;
str.Format("1+1=%d",add(1,1));
MessageBox(str);
MessageBox("over!");
sprintf(a,"%d",hdll);
MessageBox(a);
FreeLibrary(hdll);
}
点击后release版直接结束, debug版运行messagebox(a);不执行 但调试时messagebox(a)是有输出的。
{
// TODO: Add your control notification handler code here
HINSTANCE hdll=0;
hdll=LoadLibrary("dll1.dll");
char a[1];
typedef int (*addlocal)(int a,int b);
addlocal add=(addlocal)GetProcAddress(hdll,MAKEINTRESOURCE(3));
if (!add)
{
MessageBox("fail!");
return;
}
CString str;
str.Format("1+1=%d",add(1,1));
MessageBox(str);
MessageBox("over!");
sprintf(a,"%d",hdll);
MessageBox(a);
FreeLibrary(hdll);
}
点击后release版直接结束, debug版运行messagebox(a);不执行 但调试时messagebox(a)是有输出的。
不大能理解啊
debug是最后一个对话框不出现 就弹两个对话框messagebox(a)没出来 但程序整体正常不会出现对话框点完界面就消失情况 debug下跟踪程序运行 最后这个对话框能弹出来?
希望高手们解答!
如果是MFC的 debug下用debug的DLL release下用release的DLL
VERIFY(hdll=LoadLibrary("dll1.dll")); //使用绝对路径或确保dll和exe在同一目录下