Inno Setup Compiler: How to edit INI file and repl

2020-02-12 10:06发布

问题:

I have a INI file wich contains c:/wamp many times.

How can I replace this text with the {app} extended/chosen constant value?

I know now how to replace a single value:

[INI]
Filename: "{app}\wampmanager.conf"; Section: "main"; Key: "installDir"; String: """{app}"""

I am reading from here

回答1:

This is risky solution as TLama says.

You have to call this procedure at some point, e.g. on ssDone or as an AfterInstall

[Code]
procedure Update;
var
A: AnsiString;
U: String;
begin
    LoadStringFromFile(ExpandConstant('{app}\wampmanager.conf'), A);
    U := A;
    StringChange(U, 'c:/wamp', ExpandConstant('{app}'));
    A := U;
    SaveStringToFile(ExpandConstant('{app}\wampmanager.conf'), A, False);
end;


标签: inno-setup