AndreyS
AndreyS

Reputation: 385

Change Icon Index of shortcut during installation

I'm working with InstallShield 2013 Professional, Basic MSI Project.

My installation package contains exe file - myfile.exe. I added shortcut for it in Shortcuts view specifying myfile.exe as Icon File, and 0 as Icon Index. The destination place for this shortcut is a Desktop on a target box.

Suppose, my executable contains 3 icon resources and I want to change icon dynamically during Installation. To be more clear what I want to do: I have 3 radio buttons on one of Installation Dialogs and I want to apply icon to myfile.exe shortcut depending on radio button that was checked (1-st radio button->1-st icon, 2-nd radio button->2-nd icon, 3-rd radio button->3-rd icon).

How can I get this behavior? In other words, how can I change icon index of Icon File during installation?

Upvotes: 0

Views: 816

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55581

This is kind of a complicated request. An easier way of achieving this would be to compile the EXE three times with different names and different icon 0 resources and then use mutually exclusive component conditions to control which one gets installed.

It gets trickier if that's not an option. The Shortcut Table defines the IconIndex column as an integer and is not formattable. This means you can't say [ICONINDEX] in the field and let it resolve at install time.

So what can you do? You can use a custom action to dynamically emit table data into temp tables during the install. An example using C# can be found here at: Dynamic Windows Installer UI

Realize that if someone creates a shortcut by hand they are likely to pick the "wrong" icon.

Upvotes: 1

Related Questions