Advertisement

07.24.2008 at 07:52PM PDT, ID: 23594425
[x]
Attachment Details

Need assistance with UpdateResources, adding BMP to exe

Asked by Warvstars in Windows Programming

Tags: C++

I have basically the same question as this
http://www.experts-exchange.com/Programming/System/Windows__Programming/Q_20860587.html?sfQueryTermInfo=1+bitmap+resourc+updat

The accepted solution was to basically remove the first two bytes I believe. Anyway the accepted solution is not working for me, can anyone offer a solution that will work for my code. I basically need to update foot.exe with img.bmp

I'm using Visual C++ express 2008 and believe I can't use MFC.

So this is what I'm trying to do, use one.exe to update two.exe with img.bmp. one.exe is going to be using a dialog to browse for images later on.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
hRes = FindResource(hExe, L"F:\\img.bmp", RT_BITMAP); 
 
if (!hRes) 
{ 
//	return;
 
} 
 
// Load the dialog box into global memory. 
hResLoad = LoadResource(hExe, hRes); 
if (hResLoad == NULL) 
{ 
//	return;
    
} 
 
// Lock the dialog box into global memory. 
lpResLock = LockResource(hResLoad); 
if (lpResLock == NULL) 
{ 
//    return;
} 
 
 
// Open the file to which you want to add the dialog box resource. 
     HANDLE h = CreateFile(L"F:\\img.bmp", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 DWORD dw = GetFileSize(h, NULL);
 LPBYTE lpBuffer;
 lpBuffer= new BYTE[dw];
 
hUpdateRes = BeginUpdateResource(L"F:\\Foot.exe", FALSE); 
if (!hUpdateRes)
{ 
    return;
} 
 
if(!UpdateResource(hUpdateRes,RT_BITMAP, L"F:\\img.bmp",MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),lpBuffer,dw))
	{
 
		return;
	}
 
	if(!EndUpdateResource(hUpdateRes, FALSE))
	{
		return;
		
	}
[+][-]07.25.2008 at 01:31AM PDT, ID: 22086810

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 05:22AM PDT, ID: 22087788

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 05:30AM PDT, ID: 22087841

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 05:33AM PDT, ID: 22087860

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.25.2008 at 03:29PM PDT, ID: 22092747

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.26.2008 at 12:52PM PDT, ID: 22096029

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Windows Programming
Tags: C++
Sign Up Now!
Solution Provided By: Zoppo
Participating Experts: 1
Solution Grade: B
 
 
[+][-]07.26.2008 at 06:05PM PDT, ID: 22096816

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.28.2008 at 12:59AM PDT, ID: 22101346

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628