I have a program which has two different modes that users can be in. Depending on the mode I want to change the taskbar icon to reflect its state. I've found application.icon will allow me to set any image I want at run time, but there was one problem. When I installed the program, a shortcut is created for the start menu. The shortcut appears to disable the ability to change icon for the task bar. Is there any way to ignore the shortcut icon?
Asked
Active
Viewed 2,896 times
1 Answers
1
Shortcuts have nothing to do with how the application icon appears on the taskbar,
a shortcut only points to the actual executable that has the icon embedded as a resource.
Your problem could be the Windows Icon Cache. This is a common scenario where the Icon Cache isn't updated properly. You should rebuild/refresh your icon cache, then you should see the currently loaded application icon appear on the taskbar, and you can then use the Application.Icon.Load...
to swap the icons between modes.
It could also be just due to your taskbar options. If you have your taskbar set to combine both Icon + Label
then the icon does not change. Make sure that the option is set to don't combine or combine only if taskbar is full.

Peter
- 2,977
- 1
- 17
- 29
-
I manually rebuilt the icon cash and restarted my computer but the icon still resists being changed programmatically. I followed these [instructions](http://www.sevenforums.com/tutorials/49819-icon-cache-rebuild.html). I also tried to refresh it from within delphi([code](http://www.swissdelphicenter.ch/torry/showcode.php?id=1054)). The reason I thought the shortcut had some effect is because opening from the executable the task bar icon will change, but from the shortcut it wouldn't. – one two Jun 12 '13 at 17:55
-
@onetwo, how are your options for the taskbar set? If your options are set to combine icon+label then changing the icon has no effect. This is same if your taskbar is full. – Peter Jun 12 '13 at 18:08
-
Ah, my taskbar option is being set to always combine and hide the labels. Changing it fixes my problem. Thank you. – one two Jun 12 '13 at 19:01
-
I know it's too late, but this answer is incorrect. App icon sometimes changes based on the Desktop's icon. See that answer: https://stackoverflow.com/a/15246856/220425 – Maris B. Jan 13 '22 at 08:59