任何人都可以使用inno安装示例脚本来帮助我显示如何向Windows 7主机文件添加条目吗?
由于
答案 0 :(得分:4)
lmhost支持#include语句,因此您可以包含自己的主机文件,如下所示:
//call after inno setup step change
procedure UpdateLMhosts(CurStep: TSetupStep);
var
contents: TStringList;
filename, statement: String;
i: Integer;
begin
if(CurStep=ssDone) then begin
filename := ExpandConstant('{sys}\drivers\etc\lmhosts');
Log('Reading ' + filename);
contents := TStringList.Create();
if(FileExists(filename)) then begin
contents.LoadFromFile(filename);
end;
//copy my lmhosts to the system's lmhosts
statement := ExpandConstant('#INCLUDE {commonappdata}\MyBrand\MyApp\lmhosts');
if(contents.IndexOf(statement) < 0) then begin
Log('Adding' + statement);
contents.Append(statement);
contents.SaveToFile(filename);
end;
end;
end;
答案 1 :(得分:2)
这似乎是Inno Setup提供的范围之外的任务。
请参阅以下知识库文章以获取建议:http://www.jrsoftware.org/iskb.php?custom