I’m developing a simple application which is supposed to simply copy another existing executable file and change it’s icon. Is this possible to achieve with .NET? I’m asking about icon changing, copying is not a problem.
I have no clues on how and where to start. I’ve searched on Google, but found only unmanaged C++ code which I’m not very much familiar with.
This post has nothing with changing current application’s icon at runtime, rather it’s about changing the icon of an external application (that’s visible in Windows Explorer).
Any help would be appreciated.
Thanks.
.NET has no support for this whatsoever. The icon is stored in the unmanaged resources embedded in a .exe. You can see them with File + Open + File, select the .exe and open the Icons node. The lowest numbered icon is the one Windows uses.
Updating those resources normally requires rebuilding the .exe. Luckily the Windows API has support for updating resources on-the-fly. It has restrictions but that shouldn’t affect you for icons. You’ll need BeginUpdateResource, UpdateResource and EndUpdateResource. Beware that they are not easy to use, you need to know the icon resource number. Visit pinvoke.net for the declarations you will need.