Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC VC9.0 msi VC VC++
I want to know the complete method of msi installation because The msi file created when installed is not displaying the pictures that are of .png type why does this happen and how to solve this problem?
 
Before creating msi when I execute the program in the vc++2008 its showing pictures. why I am not able to view png pictures when I create the same program msi other pics of bitmap type can be viewed.
 

I have placed png pictures in res folder.
and also followed the following procedure
solution explorer->ResourceFiles->right click mouse->add existing item->(added png files of res folder)
 
What else should I do to make my png pictures appear after installing msi.
[updated]
I have used picture ctrl to display png
 
 
BOOL CPictureCtrl::Load(BYTE* pData, size_t nSize)
{
	return LoadFromStream(pData, nSize);
}
....
CPictureCtrl m_picCtrl;
CFile picFile;
	if(picFile.Open(_T("res/uprightAcousticPiano.png"), CFile::modeReadWrite | CFile::typeBinary))
	{
		cout("opened");
		BYTE* pBuffer = new BYTE[(unsigned int)picFile.GetLength()];
		if(pBuffer != NULL)
		{
			picFile.Read(pBuffer, (UINT)picFile.GetLength());
 
			//Load the Image
			cout("displayed");
				m_picCtrl.Load(pBuffer, (size_t)picFile.GetLength());
 
			delete pBuffer;
		}
	}
....
Posted 10-May-12 21:45pm
chaiein1.8K
Edited 14-May-12 20:42pm
v5
Comments
Code-o-mat at 11-May-12 6:58am
   
Do you use some library to work with png files that requires a DLL maybe? If yes, does your installer include this DLL?
chaiein at 14-May-12 23:28pm
   
no I am not using any different dll I have included below as part of the code display png
 

int myInt=0;
Patch = (unsigned char)myInt;
m_picCtrl.FreeImage();
CFile picFile;
if(picFile.Open(_T("res/acoustic grand piano_small.png"), CFile::modeReadWrite | CFile::typeBinary))
{
cout("opened");
BYTE* pBuffer = new BYTE[(unsigned int)picFile.GetLength()];
if(pBuffer != NULL)
{
picFile.Read(pBuffer, (UINT)picFile.GetLength());
 
//Load the Image
cout("displayed");
m_picCtrl.Load(pBuffer, (size_t)picFile.GetLength());
 
delete pBuffer;
}
}
enhzflep at 15-May-12 1:21am
   
What's the type of m_picCtrl?
Or, more importantly (and the information I would look up if I knew the type) - is there a return value from m_picCtrl.Load?
I'd also be checking to see if picFile.GetLength() was returning the correct values.
Otherwise, it's a bit hard to tell(guess) - the code you show above looks good. It sure sounds like an odd problem.
chaiein at 15-May-12 1:43am
   
CPictureCtrl m_picCtrl;
i have include PictureCtrl.h and .cpp
enhzflep at 15-May-12 2:03am
   
Reading the comments below makes me wonder how you're linking to the MFC / VC libs. I use VS too infrequently to recall what kind of error message would be thrown - but have you tried to Statically Link these libraries - that is, not rely on DLLs in your exe?
chaiein at 15-May-12 2:13am
   
i used shared dll library too Its same problem. If I change to other window libraries then i have problem in installing in other pc.
enhzflep at 15-May-12 2:25am
   
If I understand you correctly:
 
a) You use DLLs (Project->Properties->Configuration Properties->General->Project Defaults : "Use of MFC" = "Use MFC in a shared DLL"
 
b) When you change this setting to "Use Standard Windows Libraries", there is problem installing on other PC.
 

 
Have you tried setting this to "Use MFC in a Static Library"?
 
(You're using MFC, so it seems that "Use Standard Windows Libraries" would be unsuitable)
Reading the Help on this option:
 
Use of MFC
----------
Specifies whether the MFC project will statically or dynamically link to the MFC DLL. Non-MFC projects can select Use Standard Windows Libraries to link to various Win32 libraries that are included when you use MFC.
 
To programmatically access this property, see useOfMfc.
chaiein at 15-May-12 2:30am
   
ya i tried both static and shared
enhzflep at 15-May-12 2:32am
   
Bugger!
What a b*stard of a problem. Hope you get it fixed soon.
chaiein at 15-May-12 2:44am
   
ya I have this problem very strange I don't understand hw to solve.
chaiein at 15-May-12 1:56am
   
it returns bool value Load()
chaiein at 15-May-12 1:57am
   
It works perfect as I require before msi creation but only after msi creation and installed and try to run the png problem and warning(debug mode) or close program(release mode)comes.
 
It means its returns a correct length.
enhzflep at 15-May-12 2:06am
   
Okay, thanks. Sounds like it may be a problem with dependencies (required DLLs missing)
I would try:
a) depends.exe as suggested by barneyman
b) statically linking all required libraries (as mentioned above)
 
Not sure which would be the quicker option - they should both be quite quick depending on the size of your project.
 
[EDIT] Did you say it returns a warning in debug mode? If so, can you provide the warning message?
chaiein at 15-May-12 2:23am
   
Assertion Fail warning. Its because its trying to delete the file created.
 
According to the code it should access the file if created or create and edit the file and after that delete the handler. but this same code is not giving warning before msi creation. I too included the res while creating msi file under application folder and the folder that I am using in the project.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

have you run it under a debugger after it's been installed? I assume you're building release for install - have you tried running the release build to see its behaviour
 
Compile it under release with no code optimisations, program database (/od and /Zi respectively)
 
Link with /DEBUG
 
You can then debug, or attach, all you need is the source and the pdbs
 
Couple of observations
 
1. You're requesting RW access? do you need RW? is the file installed RO?
2. You're assuming your current working dir is above 'res\\'
3. Your directory slash is the wrong way round
  Permalink  
Comments
chaiein at 15-May-12 1:39am
   
if i use in release mode instead of warning the program closes.
barneyman at 15-May-12 1:41am
   
ok - then you have some release vs debug build issues - you're going to have to debug the release build to work out what's missing
chaiein at 15-May-12 1:44am
   
how to do that where should I change the properties?
chaiein at 15-May-12 1:49am
   
It works perfect as I require before msi creation but only after msi creation and installed and try to run the png problem and warning(debug mode) or close program(release mode)comes.
barneyman at 15-May-12 1:54am
   
I assume you're talking about installing on a different machine?
 
If that's the case, the debug problem is environmental; there is something missing on the destination machine, that you are implicitly/explicitly assuming is already there
 
The release problem points to some more fundamental issues at play; I'd solve those first if I were you - you're NOT going to be shipping debug code
 
Again - your only real option (after using depends.exe to make sure you're not missing a supporting dll) is to debug it ...
 
I've given you the switches to do that
chaiein at 15-May-12 2:05am
   
Even I same pc and different pc problem is there.even even in debug and release problem exist.
barneyman at 15-May-12 2:11am
   
excellent!
 
debug it
chaiein at 15-May-12 2:51am
   
The problem may be in msi creation what to do?
enhzflep at 15-May-12 2:01am
   
Actually, barneyman - in reference to your point #3:
 
Both "/" and "\\" are valid when constructing file-paths. The former reduces the size of your source-code by 1 (w)char per separator, though they both add 1 (w)char per separator to the executable.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

If I read your problem correctly, you're using an .msi file to install your application on another (or even your own) system.
 
Your code tries to load your .png file from a directory called "res", which is a subdirectory of the folder containing your .exe file.
 
Does your .msi also include distribution of the res folder and the .png files along with your application? If not, that is the problem since the files (and the .res dir) won't exist (except as a subdirectory of your development folder).
 
Hope this helps.
  Permalink  
Comments
chaiein at 18-May-12 3:01am
   
ya I have included res in the msi and it contains png files too and included the png also its not working.

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

  Print Answers RSS
0 OriginalGriff 270
1 Sergey Alexandrovich Kryukov 185
2 BillWoodruff 173
3 CPallini 155
4 Kamal Rocks 144
0 OriginalGriff 5,655
1 DamithSL 4,506
2 Maciej Los 3,997
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 15 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100