关于对话框DoModal()函数调用失败的原因分析(Debug Assertion Failed)
来源:互联网 发布:社交软件排行 编辑:程序博客网 时间:2024/06/05 15:10
注意 本文前部份 引自 朱金灿 的关于对话框DoModal()函数调用失败的原因分析 .
地址:http://blog.csdn.net/clever101/article/details/2576968
typedef int (__stdcall* StarViwe_)(const char * , const char * , int );
HINSTANCE hmodule_StarViwe = ::LoadLibrary ("PrintForGxNx.dll");
if( NULL != hmodule_StarViwe)
{
AfxSetResourceHandle(hmodule_StarViwe);
StarViwe_ StarViwe = (StarViwe_)::GetProcAddress(hmodule_StarViwe, "TxtToPrn");
if(NULL != StarViwe)
{
CString Printname = "";
GetDlgItem(IDC_EDIT5)->GetWindowText(Printname);
StarViwe("","",0);//调用
::FreeLibrary (hmodule_StarViwe);
AfxSetResourceHandle(AfxGetInstanceHandle( ));
}
else
{
AfxMessageBox("TxtToPrn函数地址错误!");
::FreeLibrary (hmodule_StarViwe);
}
}
else
{
AfxMessageBox("PrintForGxNx.dll加载失败");
}
(2) 主程序的版本 与 DLL 的编译版本对应,即Debug /release 的一一对应
这里再补充说明一点:
最好在DLL弹出对话框前切换模块状态
extern "C" int _declspec(dllexport) __stdcall TxtToPrn(const char * PrnName, const char * FileName, int Delete)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
PageSetDlg pdlg = new PageSetDlg();
pdlg.DoModal();
return 0;
}
做到以上的规则 基本是不会有问题的了。
但是会出现以下情况:
二、
引用别人的工程,即使做到了一中说明的规则 依然报错
那么可能的原因就是 别人生成DLL采用的是静态模式。
现在你只要去 Project-->Settings---->Genrval页面
改成动态链接 即可。
- 关于对话框DoModal()函数调用失败的原因分析(Debug Assertion Failed)
- 关于对话框DoModal()函数调用失败的原因分析
- 关于对话框DoModal()函数调用失败的原因分析
- DoModal()函数调用失败的原因分析:
- CDilog::DoModal调用失败,原因分析
- 关于异常的小程序出现debug assertion failed!错误的原因是什么?
- MFC创建非模态对话框的debug assertion failed问题
- 关于Debug Assertion Failed!的一些问题 (转载)
- dll中调用对话框,出现Debug Assertion Failed!停在 ENSURE(this != NULL)
- Debug Assertion Failed! (调出“调用栈”窗口)
- DoModal失败原因
- 在ActiveX控件对话框中添加系统自带的ocx控件出现Debug Assertion Failed
- Debug Assertion Failed
- debug assertion failed
- Debug Assertion Failed解决方法! !!
- Debug Assertion Failed!
- Debug Assertion Failed!
- debug assertion failed
- HTTP协议 (五) 代理
- 关于C语言 内存对齐的问题
- 贪心算法—删数问题
- Android上掌纹识别第一步:基于OpenCV的6种肤色分割 源码和效果图
- 把字符串转换成整数
- 关于对话框DoModal()函数调用失败的原因分析(Debug Assertion Failed)
- Mocha实践
- Python 代码调试技巧
- 变量 常量
- sqlserver2008导出数据库脚本
- ExecutorService,Executors 使用
- Warning: Unknown: POST Content-Length of 53 bytes exceeds the limit of 0 bytes in Unknown on line 0
- wmode属性的Opaque参数
- 对C++的总结