Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.
C++
//////////////////////////////////////////////////////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......
Posted
Updated 5-Dec-13 17:10pm
v3
Comments
CPallini 5-Dec-13 5:30am    
Could you pease elaborate? What kind of error did you notice?
nv3 5-Dec-13 7:43am    
How did you come to the conclusion that the marked statement is the cause of trouble. If you are just running the release version on that other PC and you have no VisualStudio installed, how can you know what the real problem is. Just because your program crashes after you have hit the OK button does not mean that the marked if-statement is the cause of trouble.
[no name] 6-Dec-13 0:16am    
It would be very good luck if someone could guess your problem from what you have provided. The fact that your program does not run on another machine is not entirely unexpected. This is normal programmer's work. Solving it usually is not done by with a silver bullet but by adopting a systematic approach. Have you made any attempt to solve this yourself before posting the question?
What does the IDOK code do? That would be my first question before concluding CFileDialog is the culprit. Does it require permissions not held by the current user?
I can state with certainty even without seeing your code that your error handling is weak.
One approach is to create a debug version of the executable peppered with assert()s and run that to get an idea of where the code is breaking.

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 - Calling CoInitializeEx(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 calling CString::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
 
Share this answer
 
v4
Did you tried statically linking the MFC support ?
project properties->Configuration properties
use of MFC->static library
 
Share this answer
 
Comments
SimJeaHwan 5-Dec-13 5:55am    
yes. I already checked that.
and I changed properties->c/c++ -> code generation -> runtime library -> MT

not work.....T.T

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900