I want to produce two different versions of my application, with different icons based on a DEFINE.
I succeeded to include different resource files based on the define but I cannot get rid of the MAINICON in the default .res file of my project.
I added a resource Version1.rc file with the following line:
MAINICON icon "resource\icons\Version1.ico"
But if I try to compile MyProject using the IDE I always get the following error:
E2161 Duplicate resource: Type 14 (ICON GROUP), ID MAINICON; File C:\MyProject\Version1.RES resource kept; file C:\MyProject\MyProject.RES resource discarded.
I tried to edit MyProject.res using a resource editor and deleted MAINICON, but delphi automatically seems to recreate the file including the icon.
I found a solution thanks to the comments of David Heffernan. I ended up with the following:
{$R *.res}in the project file.versioninfo.rcwith the information, that I formerly provided in the IDE, as described here.I added the files
icon_version1.rcandicon_version2.rc, that looked like this:I added a file
Resources.pasto my project, that looked like this:I modified my existing script
compile_resources.batto compile the additional resource files.Now if I define
VERSION1, my application has the iconicon_version1.ico, otherwiseicon_version2.ico. One caveat: If version info (or icon) is modified I have to runcompile_resources.batto reflect the changes.