1
votes

In my code section I need to modify an existing configuration file (Apache httpd.conf) to include one of the files I'm installing in the Files section.

How can I reference my .conf file, so I can insert into the httpd.conf something like this:

Include "C:/Program Files (x86)/Apache Software Foundation/Apache2.4/conf/myinclude.conf"

I think I can do something like:

 ExtractFilePath( {app} ) + '\conf\myinclude.conf' 

to get the full path of the file.

However that means I have to hard code the partial path in my script code. If we later change the path then I have to change it in the files section and remember to change it in the script code too.

Is there a way to reference the file just by name and get the full installed path?

Secondary question:
What's the best place to do this kind of thing (modifying a file)?

  1. In the AfterInstall of the file I'm going to modify it for?
  2. In NextButtonClick on wpFinished?
  3. Other?
1
I suppose I could define a variable for the partial path and use that everywhere - that would resolve the issue of having to change it in multiple places. However I'm still new to INNO so not sure if I can get a variable to expand everywhere I might need it. - Toby

1 Answers

1
votes

Use a preprocessor constant/variable.

The best place to update the httpd.conf is CurStepChanged(ssPostInstall). The AfterInstall will do too.

#define MyIncludeName "myinclude.conf"
#define MyIncludeRelPath "conf\" + MyIncludeName

[Files]
Source: "{#MyIncludeName}"; DestDir: "{app}\..\{#MyIncludeRelPath}"

[Code]

procedure CurStepChanged(CurStep: TSetupStep);
var
  Path: string;
begin
  if CurStep = ssPostInstall then
  begin
    Path := ExtractFilePath(ExpandConstant('{app}')) + '{#MyIncludeRelPath}';
    ...
  end;
end;