Programmatically change the icon of the executable

Posted by Dennis Delimarsky on Stack Overflow See other posts from Stack Overflow or by Dennis Delimarsky
Published on 2010-03-29T15:23:24Z Indexed on 2010/03/29 15:33 UTC
Read the original article Hit count: 187

Filed under:
|
|
|
|

I am developing an application called WeatherBar. Its main functionality is based on its interaction with the Windows 7 taskbar — it changes the icon depending on the weather conditions in a specific location.

The icons I am using in the application are all stored in a compiled native resource file (.res) — I am using it instead of the embedded resource manifest for icons only. By default, I modify the Icon property of the main form to change the icons accordingly and it works fine, as long as the icon is not pinned to the taskbar. When it gets pinned, the icon in the taskbar automatically switches to the default one for the executable (with index 0 in the resource file).

After doing a little bit of research, I figured that a way to change the icon would be changing the shortcut icon (as all pinned applications are actually shortcuts stored in the user folder). But it didn't work.

I assume that I need to change the icon for the executable, and therefore use UpdateResource, but I am not entirely sure about this. My executable is not digitally signed, so it shouldn't be an issue modifying it.

What would be the way to solve this issue?

© Stack Overflow or respective owner

Related posts about c#

Related posts about Windows