CFileDialog发布模式错误 [英] CFileDialog release mode error
问题描述
我使用visual studio 2010,
我写了程序并制作了exe文件。 (发布模式)
它在我的电脑上运行良好。
但它不适用于其他电脑。
那里没有安装visual studio。
所以我在我的程序中检查了一个日志文件。
< pre lang =c ++> /// //////////////// ///////////////////////////////////问题代码
CString FILE_NAME_A,FILE_NAME_B;
CFileDialog dlg(TRUE, bmp, * .bmp,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
bmp文件打开(* .bmp)| * .bmp |所有文件(*。*)| *。* |);
if (dlg.DoModal()== IDOK)
{
}
/// ////////////////////////// /////////////////////////问题代码
if (dlg.DoModal()== IDOK) // < - 它的问题
当我点击OK按钮然后它就失效了。
谁知道这个问题.. ..TT
PLZ回答......
这可能是非常棘手的,因为各种第三方应用程序和工具可以将自己附加到对话框中。您还可以体验不同的行为,具体取决于您运行的Windows版本。我列出了一些你可以尝试的方法。
1 - 呼叫CoInitializeEx(COINIT_MULTITHREADED)
首先,您应该查看作为消息发布到CodeProject上的文章的解决方案: XFolderDialog - 基于CFileDialog的文件夹选择对话框 [ ^ ]。他在阅读本文后找到了修复程序: http://support.microsoft.com/kb/287087 [ ^ ]。
2 - Sloppy代码,例如在调用CString :: GetBuffer()
你也可能没有向我们展示所有相关的代码,你的问题类似于Jochen Arndt在这里回答的问题:cFileDialog DoModal Exception [ ^ ]。
3 - 关闭Vista样式
另一种选择是尝试不在Vista样式中显示对话框: http://social.msdn.microsoft.com/Forums/vstudio/en-US/0e8762c9-cc99-49ec-9c06-4c6824114db9 / riddle-me-this-domodal?forum = vcgeneral [ ^ ]
4 - 追踪错误的第三方扩展
如果上述方法都没有帮助您解决问题,则需要查看第三方应用程序和工具,这些应用程序和工具已挂钩到对话框中。请参阅这些文章:
http://mfctips.com/2012 / 10/29 / cfiledialogdomodal-cause-access-violation / [ ^ ]
http: //computer-programming-forum.com/82-mfc/f4f6bf48f940e6eb.htm [ ^ ]
Soren Madsen
您是否尝试过静态链接MFC支持?
项目属性 - >配置属性
使用MFC->静态库
I use visual studio 2010,
I written program and made "exe file". (release mode)
It work well in my PC.
but it's not work other PC well.
there's not install visual studio.
So I checked a log file in my program.
//////////////////////////////////////////////////////problem code
CString FILE_NAME_A,FILE_NAME_B;
CFileDialog dlg( TRUE, "bmp", "*.bmp", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
" bmp File Open(*.bmp) |*.bmp| All File(*.*) |*.*|");
if(dlg.DoModal() == IDOK)
{
}
//////////////////////////////////////////////////////problem code
if(dlg.DoModal() == IDOK) //<-- it's problem
when i click OK button then it's down.
who's know this problems....T.T
PLZ answer......
This can be pretty tricky to dig into because all kinds of 3rd party applications and tools can have attached themselves to the dialog. You can also experience different behavior depending on which version of Windows you are running on. I have listed a number of approaches below that you can try out.
1 - CallingCoInitializeEx(COINIT_MULTITHREADED)
First you should look into the solution posted as a message to an article here on CodeProject: XFolderDialog - a folder selection dialog based on CFileDialog[^]. He found the fix after reading this article: http://support.microsoft.com/kb/287087[^].
2 - Sloppy code, such as not releasing the buffer after callingCString::GetBuffer()
It is also possible that you have not shown us all the relevant code and your problem is similar to what was fixed in Jochen Arndt's answer here: cFileDialog DoModal Exception[^].
3 - Turn off Vista Style
Another option is to try to not show the dialog in "Vista Style": http://social.msdn.microsoft.com/Forums/vstudio/en-US/0e8762c9-cc99-49ec-9c06-4c6824114db9/riddle-me-this-domodal?forum=vcgeneral[^]
4 - Tracking down faulty 3rd party extension
If none of the above approaches helped you solve the problem, you need to look at the 3rd party applications and tools that have their hooks into the dialog. See these articles:
http://mfctips.com/2012/10/29/cfiledialogdomodal-causes-access-violation/[^]
http://computer-programming-forum.com/82-mfc/f4f6bf48f940e6eb.htm[^]
Soren Madsen
Did you tried statically linking the MFC support ?
project properties->Configuration properties
use of MFC->static library
这篇关于CFileDialog发布模式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!