0

I want to change icon on remote exe with one that is stored in RC_DATA in my original program (exe)

I'm using VC6

where is the error?

here's the code

HINSTANCE hExe = LoadLibrary(nameExe);
// first icon
HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(101), RT_GROUP_ICON);
HGLOBAL hResLoad = LoadResource(NULL, hRes);
PBYTE lpResLock = (PBYTE) LockResource(hResLoad);
int nID = LookupIconIdFromDirectory(lpResLock, TRUE );

HRSRC hRes2 = FindResource(NULL, MAKEINTRESOURCE(nID), MAKEINTRESOURCE(RT_ICON));
HGLOBAL hResLoad2 = LoadResource(NULL, hRes2);
PBYTE lpResLock2 = (PBYTE) LockResource(hResLoad2);

//second icon
HRSRC hRes3 = FindResource(NULL, MAKEINTRESOURCE(102), RT_GROUP_ICON);
HGLOBAL hResLoad3 = LoadResource(NULL, hRes3);
PBYTE lpResLock3 = (PBYTE) LockResource(hResLoad3);
int nID1 = LookupIconIdFromDirectory(lpResLock3, TRUE );

HRSRC hRes4 = FindResource(NULL, MAKEINTRESOURCE(nID1), MAKEINTRESOURCE(RT_ICON));
HGLOBAL hResLoad4 = LoadResource(NULL, hRes4);
PBYTE lpResLock4 = (PBYTE) LockResource(hResLoad4);
	
HANDLE hUpdateRes = BeginUpdateResource(nameExe, FALSE );
				
UpdateResource(hUpdateRes, RT_GROUP_ICON, MAKEINTRESOURCE(101),MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) , lpResLock4, SizeofResource(hExe, hRes4));
EndUpdateResource(hUpdateRes, FALSE);

where is the error?

Edited by suncica2222: n/a

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by usagi
0

icons etc are loaded using a seperate resource.rc file which looks somethings like this

IDR_APP_ICON ICON "iconname.ico"

I might have missunderstood your question though.

Edited by usagi: n/a

0

I'm not sure what you mean with "remote exe", remote as another place on your machine or remote as in on another computer?

If it's just some other place on your computer and you know where to open it how about reading the file as binary and re-write the part that contains the icon?
To know what to change and how it looks you first create a copy of the remote exe and replace the icon with the one you want in using a resource editor, then you compare the two files and store those changes to your main program.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.