开发者

INNO Setup: Defining Configuration Files in Setup Package

开发者 https://www.devze.com 2022-12-18 13:00 出处:网络
This is probably a simple fix but I can\'t seem to wrap my head around it.I have an app to install that will need the user to select 1 of 3 possible INI files to accompany the install.I could easily d

This is probably a simple fix but I can't seem to wrap my head around it. I have an app to install that will need the user to select 1 of 3 possible INI files to accompany the install. I could easily do 3 different setups, each using a different INI but I would like to simplify matters and just give the user the choice of INI at the time of install. The INI files have the same name, so when packaged they will have to be given different names. Once the user selects which INI to install, it would be extracted into the app dire开发者_运维技巧ctory and renamed. Is there any way to do this?

Thanks for your help!


You can add entries for all three INI files to the [Files] section, give them the same destination name, and use the Check parameter to decide at runtime which single one gets installed. A snippet from one of my install scripts:

[Files]
Source: "{src}\Line1.ini"; DestDir: "{app}"; DestName: "Line.ini"; \
    Flags: external; Check: IsLine1
Source: "{src}\Line2.ini"; DestDir: "{app}"; DestName: "Line.ini"; \
    Flags: external; Check: IsLine2
Source: "{src}\Line3.ini"; DestDir: "{app}"; DestName: "Line.ini"; \
    Flags: external; Check: IsLine3

And the support functions in the [Code] section:

function IsLine(ID: integer): boolean;
begin
  Result := (ID = 1 + LinePage.SelectedValueIndex);
end;

function IsLine1(): boolean;
begin
  Result := IsLine(1);
end;

function IsLine2(): boolean;
begin
  Result := IsLine(2);
end;

function IsLine3(): boolean;
begin
  Result := IsLine(3);
end;

where LinePage is a custom page of type TInputOptionWizardPage. The user selects with a radio group for which production line the program is to be installed, and only the matching INI file is copied. Note that they are external in my case, but they could just as well be compiled into the setup.


A possible way is to create a [Run] section (or add to it) and execute (AfterInstall: parameter) a Pascal routine that delete the extra ini files and rename the remaining one.

0

精彩评论

暂无评论...
验证码 换一张
取 消