Click here to Skip to main content
15,921,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: source code from exe Pin
ThatsAlok6-Mar-05 18:17
ThatsAlok6-Mar-05 18:17 
GeneralRe: source code from exe Pin
Gary R. Wheeler5-Mar-05 2:19
Gary R. Wheeler5-Mar-05 2:19 
GeneralEnumerating ip addresses Pin
lastdays5-Mar-05 1:24
lastdays5-Mar-05 1:24 
GeneralRe: Enumerating ip addresses Pin
lastdays5-Mar-05 1:35
lastdays5-Mar-05 1:35 
QuestionHow do I get the dialog controls palette back ??? Pin
Still learning how to code5-Mar-05 0:41
Still learning how to code5-Mar-05 0:41 
AnswerRe: How do I get the dialog controls palette back ??? Pin
Gary R. Wheeler5-Mar-05 1:43
Gary R. Wheeler5-Mar-05 1:43 
GeneralRe: How do I get the dialog controls palette back ??? Pin
Still learning how to code5-Mar-05 3:25
Still learning how to code5-Mar-05 3:25 
GeneralPlease help Pin
Nemok4-Mar-05 23:16
Nemok4-Mar-05 23:16 
Hi guys,

I am developing a program that replaces executables icons with icons from other applications (executables) or from icon files. For now I am using this code in order to do it:
<br />
HMODULE hLibrary;<br />
	HRSRC hResource;<br />
	HGLOBAL hResourceLoaded;<br />
	LPBYTE lpBuffer;<br />
	HICON hIcon;<br />
	int skip=0;<br />
	<br />
	hLibrary = LoadLibrary(icon);<br />
	if((int) ExtractIcon(AfxGetInstanceHandle(), icon, (UINT) -1))<br />
		for(unsigned long n=0;n<=1000000;n++)<br />
		{<br />
			hResource = FindResource(hLibrary,MAKEINTRESOURCE(n), RT_ICON);<br />
			if(hResource)<br />
				if(skip==IconIndex)<br />
					n=1000001;<br />
				else<br />
					skip++;<br />
		}<br />
	else<br />
		MessageBox("The icon file or the first file contains no icon");<br />
	if(hResource)<br />
	{<br />
		hResourceLoaded = LoadResource(hLibrary,hResource);<br />
		lpBuffer = (LPBYTE) LockResource(hResourceLoaded);            <br />
		hIcon=CreateIconFromResource((PBYTE)lpBuffer,SizeofResource(hLibrary,hResource),1,0x00030000);<br />
<br />
		HANDLE hUpd=BeginUpdateResource(my_name,0);<br />
		UpdateResource((HMODULE)hUpd,RT_ICON,MAKEINTRESOURCE(1),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),lpBuffer,SizeofResource(hLibrary,hResource));<br />
		EndUpdateResource(hUpd, FALSE);<br />
	}<br />
	FreeLibrary(hLibrary);<br />

So now I am using LoadLibrary, FindResource, LockResource to extract icon from executable or dll and then I use UpdateResource(...) to write icon to new exe. The problem is that this options does not suport icon files (.ico) and also it doesn't allow the user to extract the specified icon. I am using ExtractIcon() to get icon number.

Another way, more efficient and better would be to use ExtractIcon() to get icon form exe, dll or ico file. The problem of this mettod is that ExtractIcon() does not return a pointer to the data to be written by UpdateResource(...) instead it returns a HICON handle.
My question is how could I write this HICON handle to the new exe using UpdateResource(...). Itried several different methods but achieved one worked?

Please help anyone, this is very important to me.

Thanks.
GeneralDelete file at startup or shutdown Pin
Anonymous4-Mar-05 23:12
Anonymous4-Mar-05 23:12 
GeneralRe: Delete file at startup or shutdown Pin
tanvon malik5-Mar-05 1:07
tanvon malik5-Mar-05 1:07 
GeneralRe: Delete file at startup or shutdown Pin
Anonymous5-Mar-05 4:51
Anonymous5-Mar-05 4:51 
GeneralRe: Delete file at startup or shutdown Pin
Ravi Bhavnani5-Mar-05 7:51
professionalRavi Bhavnani5-Mar-05 7:51 
GeneralRe: Delete file at startup or shutdown Pin
Max Santos5-Mar-05 9:39
Max Santos5-Mar-05 9:39 
GeneralRe: Delete file at startup or shutdown Pin
Nemok6-Mar-05 0:26
Nemok6-Mar-05 0:26 
GeneralRe: Delete file at startup or shutdown Pin
ThatsAlok6-Mar-05 18:28
ThatsAlok6-Mar-05 18:28 
GeneralInclude statements Pin
MALDATA4-Mar-05 22:31
MALDATA4-Mar-05 22:31 
GeneralRe: Include statements Pin
Johnny ²4-Mar-05 22:56
Johnny ²4-Mar-05 22:56 
GeneralRe: Include statements Pin
Trollslayer5-Mar-05 8:43
mentorTrollslayer5-Mar-05 8:43 
GeneralRe: Include statements Pin
MALDATA5-Mar-05 13:06
MALDATA5-Mar-05 13:06 
GeneralDialog box hangs help me Pin
Anand for every one4-Mar-05 19:43
Anand for every one4-Mar-05 19:43 
GeneralRe: Dialog box hangs help me Pin
Blake Miller7-Mar-05 12:14
Blake Miller7-Mar-05 12:14 
GeneralRe: Dialog box hangs help me Pin
Anand for every one7-Mar-05 18:56
Anand for every one7-Mar-05 18:56 
GeneralRe: Dialog box hangs help me Pin
Blake Miller8-Mar-05 3:53
Blake Miller8-Mar-05 3:53 
GeneralRe: Dialog box hangs help me Pin
sps-itsec4613-Jan-06 0:14
sps-itsec4613-Jan-06 0:14 
GeneralRe: Dialog box hangs help me Pin
sps-itsec4616-Jan-06 5:26
sps-itsec4616-Jan-06 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.