Change Icon of EXE file through code extracting it from other EXE file

Discussion in 'MFC' started by shabbir, Mar 18, 2006.

  1. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    It occurs when there is not enough buffer in the target executable.

    For this you can refer to Updating version information at run-time at codeproject
     
  2. JohnnyH

    JohnnyH Guest

    Hi shabbir, thanks for responding. I have seen the reference you pointed me to, but it's not quite the same scenario. The example at codeguru is updating the version number (at runtime) in a Version resource that is already compiled into the executable. In my case, I am trying to copy a version resource from one executable into another executable that doesn't have any resources compiled into it at all. I am wondering if you know of a way to do that or if it is possible. What I am trying to do works if the destination executable has a resource (any resource ie. icon, dialog etc.) compiled into it already, but it doesn't work if the destination executable doesn't have a resource compiled into it already.

    Thanks,
    John
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    JohnnyH, can you share your code so that we can have a look at it. I would suggest using a new thread in the Queries and Discussion forum.
     
  4. jackl007

    jackl007 New Member

    Joined:
    Aug 10, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    what happend with the complete proyect.. i want to changer the icon from a EXE using my EXE.
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I could not get you? Can you please explain a bit more.
     
  6. ibraheempindi

    ibraheempindi New Member

    Joined:
    Aug 22, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    hy! hope you'll be fine, thanks for the code but could you please explain about the limitations, i mean which sort of ico on which it will work, coz i tried several exe's from my program files but didnt work on any of them.....may be coz of different sizes, but could you please also attach any sample exe's on which the code is working properly, thanks again once again for sharing such a valuable thing...have a nice day
    best regards
    Ibraheem
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    It will work on any exe but will work on the first Icon that will be replaced but if any exe has 10 blank icons resource it will not work which is commented as well. See Just to prevent from infinite comment.

    Working sample is already there for you to see and run.
     
  8. ibraheempindi

    ibraheempindi New Member

    Joined:
    Aug 22, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    thanks ....but i wsn't still able to change icon of any exe, could you please send me any two exe's just for example, i didn't find any sample exe's to use as source and destination exe's with in your attachments on which it will work......waiting anxiously for your reply.
     
  9. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    There is a "Attached Files" section after the article where you should find the sample attachment as well.
     
  10. ibraheempindi

    ibraheempindi New Member

    Joined:
    Aug 22, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    i have both of them, one contained the project source while other contains the binary, but there is no sample exe's to use as source and dest on which it will work...... :rolleyes:
     
  11. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You can keep the exe and its copy and then run the application with the source file as some notepad and the destination one as the copy exe and then it will update the copy exe correctly. It will work on exe which has only one Icon embedded.
     
  12. ibraheempindi

    ibraheempindi New Member

    Joined:
    Aug 22, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    yeah...that's why may be its not working with mine ones...but in prof products its rare to hve one icon, and each icon have several images, i'm trying to update one, and playing around with it, but it merges some images of an ico file from destination and some from source in the same ico file.....is it posb to make it work for multiple icon embeded application and to update an ico resource with multiple images in it....thanks for your time
     
  13. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    The code can always be updated to change all the icons. I have given here how to do it (a prototype) and it can always be extended. Isn't it?
     
  14. ibraheempindi

    ibraheempindi New Member

    Joined:
    Aug 22, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    hmmm..i think soo....by changing these two params,
    one is the 3rd param of updateresource and other is FindResource 2nd param in source exe, you can browse arount the images placed in that ico file, and replace as you wish them to be, so its working now, but could you give me some hints that instead of source exe, if i have to load an *.ico image file and then replace the resource in the desitnation exe...how it would be...thanks and have a nice day :)
     
  15. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Read through the comments and you will find that as well.
     
  16. mudasir

    mudasir New Member

    Joined:
    Oct 29, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Dear Shabir
    i have run ur code to change the icon of an exe file .But i change the icon of an exe file only once.next time u run this code nothing happens(until i restart my computer).in fact in output window a message is displayed which is

    The therad 'win32 Thread' has exited with code 0 (0*0)
    The program '[3628]' Exeupdate.exe Native ' has exited with code 0 (0*0)

    will u plz guide me about this problem.
     
  17. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I am unable to re-create your problem but it looks like the exe file you are trying to change is locked by some process and it may be the ExeUpdater which is used for first time. Check if that is the case.
     
  18. mudasir

    mudasir New Member

    Joined:
    Oct 29, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Let me explain
    when i run this code then the icon of my exe file flushes once to new ion then again becoms the original icon.(e.g i want to change of msn.exe Icon with yahoo.exe Icon but msn icon again changes to msn Icon).
     
  19. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Try seeing in resource hacker and see if it gets replaced by some icon / icon group and then MSN flushes and shows some other icon group in explorer.
     
  20. parvez.yu

    parvez.yu New Member

    Joined:
    Feb 14, 2008
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    0
    i tried it is so nice
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice