【问题标题】:Inno setup edit xml file Without Change other dataInno setup edit xml file without Change other data
【发布时间】:2017-03-09 22:51:40
【问题描述】:

这是我的 XML

测试版:

选择加入:假

下载:

altState: false ..>>>>>>>> "如何使用 Inno Setup 将这个 False 更改为 true"

控制状态:假

请帮帮我

【问题讨论】:

标签: inno-setup


【解决方案1】:

做一个sed函数

// sed(file_to_edit, 'original_text', 'new_text');
function sed(fname: String; Orig: String; Moded: String): Boolean;
var
  fhandle: AnsiString;
  fhandle_uni: String;
begin;
  Result := LoadStringFromFile(WizardDirValue() + '\' + fname, fhandle);
  if Result = True then
  begin
    fhandle_uni := String(fhandle);
    StringChangeEx(fhandle_uni, Orig, Moded, True);
    Result := SaveStringToFile(WizardDirValue() + '\' + fname, AnsiString(fhandle_uni), False);
  end;
end;

WizardDirValue() 是安装目录,安装完成后会编辑文件。

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurpageID = wpFinished then
  begin;
    sed('file.xml', 'altState: false', 'altState: true')
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
  begin;
    sed('file.xml', 'altState: false', 'altState: true')
  end;
end;

两者都应该工作。

【讨论】:

  • sed("file.xml", "altState: false", "altState: true") >line get innosetup 语法错误如何修复它,我可以像这样使用它 sed("{app }\file.xml", "altState: false", "altState: true") 我使用 inno setup Unicode 版本请帮忙。链接图片:imgur.com/a/TbGk2。感谢您的帮助。
  • 你需要手动更改",从这里复制的时候就不一样了。
  • Pascal 不使用双引号。它使用单引号。您甚至尝试过编译代码吗?
  • 感谢它的工作。如何更改 WizardDirValue() 像 {userappdata}\Myapp\file.xml
  • ExpandConstant('{userappdata}')+'\Myapp\'+fname
猜你喜欢
  • 2022-01-24
  • 1970-01-01
  • 2022-12-19
  • 1970-01-01
  • 2013-01-23
  • 1970-01-01
  • 1970-01-01
  • 2016-05-15
相关资源
最近更新 更多