Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/articles/mfc-tutorials/)
-   -   Change Icon of EXE file through code extracting it from other EXE file (http://www.go4expert.com/articles/change-icon-exe-file-code-extracting-t643/)

kylls 29May2008 03:03

Re: Change Icon of EXE file through code extracting it from other EXE file
 
tanks man !

jefri_btc 12Aug2008 20:29

Re: Change Icon of EXE file through code extracting it from other EXE file
 
I need source code in Visual basic 2005 or 2008
Please Help ME

BokiSergy 20Aug2008 18:56

Re: Change Icon of EXE file through code extracting it from other EXE file
 
Quote:

Originally Posted by jefri_btc
I need source code in Visual basic 2005 or 2008
Please Help ME

Hi my friend, I saw you search the vb code for changing icon of *.exe. Well, someone is wrote a good code in vb. I hope its ll be usefull to you, and solve your task of bad luck years seaching :nice:

http://www.planet-source-code.com/vb...59973&lngWId=1

cheers!!!

limon 29Sep2008 15:52

Re: Change Icon of EXE file through code extracting it from other EXE file
 
I saw programs that can show you the ICONS in an executable files and so I thought if we can see them then definitely we can edit them as well. If we can edit them then there is a way to give them a different ICON to be displayed in the explorer.

coder_gate 27Jan2009 10:39

Re: Change Icon of EXE file through code extracting it from other EXE file
 
how are you doing extract icon from this code

PHP Code:

#include<stdio.h>
#include<windows.h>
#include <stdlib.h>
#include<iostream.h>

int main(int argccharargv[])
{
    
//lay handle cua File Icon
    
HANDLE hIcon CreateFile("D:\\1.ico",
        
GENERIC_READ,
        
0,
        
NULL,
        
OPEN_EXISTING,
        
FILE_ATTRIBUTE_NORMAL,
        
NULL);
    if (!
hIcon)
    {
        
printf("khong the tao icon");
        return 
1;
    }
    
    
LPBYTE lpBuf;
    
DWORD dwFileSizedwBytesRead;
    
    
dwFileSize GetFileSize(hIconNULL);  //lay kich thuoc cua no
    
cout<<dwFileSize;
    
lpBuf = (LPBYTE)malloc(dwFileSize);
    if (!
lpBuf)
    {
        
CloseHandle(hIcon);
        
printf("khong the cap phat dong");
        return 
1;
    }
    
    
ReadFile(hIconlpBufdwFileSize, &dwBytesReadNULL);
    if (
dwBytesRead != dwFileSize)
    {
        
free(lpBuf);
        
CloseHandle(hIcon);
        
printf("khong the doc FIle");
        return 
1;
    }
    
    
CloseHandle(hIcon);
    
    
    
HANDLE hUpdateRes;
    
hUpdateRes BeginUpdateResource("D:\\1.exe"FALSE);
    if (
hUpdateRes == NULL)
    {
        
free(lpBuf);
        
printf("khong the mo File");
        return 
1;
    }
    
    if (!
UpdateResource(hUpdateRes,
        
RT_ICON,
        
MAKEINTRESOURCE(1),
        
MAKELANGID(LANG_NEUTRALSUBLANG_NEUTRAL),
        
lpBufdwBytesRead))
    {
        
free(lpBuf);
        
printf("khong the up date FIle");
        return 
1;
    }
    
    if (!
EndUpdateResource(hUpdateResFALSE))
    {
        
free(lpBuf);
        
printf("khong the ket thuc");
        return 
1;
    }
    
    
free(lpBuf);
    
    
printf("Hello World!\n");
    return 
0;



jambo 2May2009 01:25

Re: Change Icon of EXE file through code extracting it from other EXE file
 
Hi, I downloaded second attachement, tried it in two files but didn't work ??

shabbir 2May2009 09:24

Re: Change Icon of EXE file through code extracting it from other EXE file
 
Quote:

Originally Posted by jambo (Post 46881)
Hi, I downloaded second attachement, tried it in two files but didn't work ??

Try and see if it works with the exe's I have mentioned.

jambo 4May2009 04:26

Re: Change Icon of EXE file through code extracting it from other EXE file
 
shabbir, I am having trouble with the API's. The second parameter of FindResource, msdn says it has to be the resource's name, so if I am extracting an icon from an exe how am I supposed to know it's name ?? what did u do with the '#' thing lol ?
Also the 3rd and 4th parameters of updateresource method, dunno much what to put there, especially the language thing!!
Can you explain to me ? :$

shabbir 4May2009 08:37

Re: Change Icon of EXE file through code extracting it from other EXE file
 
Quote:

Originally Posted by jambo (Post 46987)
shabbir, I am having trouble with the API's. The second parameter of FindResource, msdn says it has to be the resource's name, so if I am extracting an icon from an exe how am I supposed to know it's name ?? what did u do with the '#' thing lol ?

The Name of the Icon is mainly an integer

This Code should explain that

Code:

   
    // Locate the ICON resource in the .EXE file.
    for(iLoop = 1;;iLoop++)
    {
        CString str;
        str.Format("#%d",iLoop);
        hRes = FindResource(hSrcExe, str, RT_ICON);
        if (hRes == NULL)
            continue ;
        else if(iLoop == 10)
            return;
        else
            break;
    }

Checking only first 10 resources as this is only for tutorial purpose.

Quote:

Originally Posted by jambo (Post 46987)
Also the 3rd and 4th parameters of updateresource method, dunno much what to put there, especially the language thing!!
Can you explain to me ? :$

Look at the code in the article and its pretty much self explanatory as well as commented.

jambo 5May2009 03:01

Re: Change Icon of EXE file through code extracting it from other EXE file
 
Of course I have read the code and the comments, however, UpdateResource in my code always returns false and l have some questions that are still left unanswered and I would be very happy if you could answer them.

Why did you need to Loop to find the icon ? Does this mean :
a) a file has more than one icon ?
b) FindResource checks resource one by one??

Quote:

Originally Posted by shabbir (Post 46994)
The Name of the Icon is mainly an integer

..a string... an integer..or even a humain if it wants to, my problem is how to know what it is, I don't care it's type. I have no idea what to fill in this parameter and I don't understand what's the '#' for.

What is MAKEINTID(1) ? some function I need to declare ??
And what's that thing with the language lol ? I mean, seriously, since when language is relevant to us ??

I want to cry

:D


All times are GMT +5.5. The time now is 21:23.