我希望安装程序在没有提示消息的情况下静默编辑 xml 文件,如果 xml 文件存在于目标位置,则安装程序对其进行编辑,如果目标位置不存在,则安装继续并忽略 xml 文件执行没有提示信息就不存在。我看到了 CodeAutomation.iss 但这对我没有帮助。请帮助提供代码示例。
[Files]
Source: GameConfiguration.xml; DestDir: "{pf}\Game\Sala"; Flags: uninsneveruninstall;
procedure SaveValueToXML(const AFileName, APath, AValue: string);
var
XMLNode: Variant;
XMLDocument: Variant;
begin
XMLDocument := CreateOleObject('Msxml2.DOMDocument.6.0');
try
XMLDocument.async := False;
XMLDocument.load(AFileName);
if (XMLDocument.parseError.errorCode <> 0) then
MsgBox('Install Garena. ' +
XMLDocument.parseError.reason, mbError, MB_OK)
else
begin
XMLDocument.setProperty('SelectionLanguage', 'XPath');
XMLNode := XMLDocument.selectSingleNode(APath);
XMLNode.text := AValue;
XMLDocument.save(AFileName);
end;
except
MsgBox('Install Garena', mbError, MB_OK);
end;
end;
function NextButtonClick2(PageID: Integer): Boolean;
begin
Result := True;
if (PageId = wpFinished) then begin
SaveValueToXML(ExpandConstant('{pf}\Game\Sala\GameConfiguration.xml'), '//@param', PEdit.Text);
SaveValueToXML(ExpandConstant('{pf}\Game\Sala\GameConfiguration.xml'), '//@path', ExpandConstant('{reg:HKCU\SOFTWARE\xxx,InstallPath}\xxx.exe'));
end;
end;