7

How can I change *.EXEs icons from c# code (not my main app icon but from that app i want to change the icon of another exe).

I eventually would have to change the icons for A LOT of files so I am looking for a fast and good performance way to do it.

I have been googling for 30min but all I found is how to set the icon for the app in VS.

flyout
  • 497
  • 1
  • 9
  • 16
  • 1
    Bizarre request, some kind of "friendly" malware? – Hans Passant Jun 07 '10 at 15:14
  • @Hans: While I have seen malware that does this, there are legitimate uses as well. I'll actually be doing this soon myself to make executable config files (that can find the actual application by searching a list of paths) with customizable icons. – SLaks Jun 07 '10 at 16:15
  • No its not a friendly malware, its pretty bad ass. jk – flyout Jun 07 '10 at 17:38

3 Answers3

5

You need to call the Resources API methods, as described here.

Specifically, you need to call BeginUpdateResource, UpdateResource, and EndUpdateResource.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Maybe I'm missing something, but the links here point out to a C++ API while the OP question was about C# – gilad905 Jun 02 '23 at 09:22
0

See this. http://www.angusj.com/resourcehacker/

It is definitely not through C# but its eventually fast and good performance way as you asked.

EDIT
All About Resource Hacker in a Brief Tutorial

IsmailS
  • 10,797
  • 21
  • 82
  • 134
  • He wants to do it programatically. – SLaks Jun 07 '10 at 14:22
  • Yep, I need to do it from inside my app, I already use res hacker sometimes, maybe if rh was a console app I could integrate in my code but I bet that would be kinda slow. – flyout Jun 07 '10 at 14:38
0

Rather than hacking the resource in the .exe (not very friendly), you could instead create a shortcut to the exe, which will allow you to easily use your own icon in the shortcut. See here for more info on how to do this, using the ShellLink class.

Community
  • 1
  • 1
Polyfun
  • 9,479
  • 4
  • 31
  • 39