-2

this is My Xml

betas:

optIn: false

downloads:

altState: false ..>>>>>>>> "How to change This False to true Using Inno Setup"

controlState: false

Please Help me

Thilanka
  • 7
  • 2

1 Answers1

0

Do a sed function

// 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() is the installation dir, this will edit the file after finishing installation.

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

or

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

both should work.

cpatricio
  • 457
  • 1
  • 5
  • 11
  • sed("file.xml", "altState: false", "altState: true") >line get innosetup syntax error How to fix it and can i use it like this sed("{app}\file.xml", "altState: false", "altState: true") im use inno setup Unicode version please help. Link pic: http://imgur.com/a/TbGk2 .thank for your help. – Thilanka Oct 27 '16 at 15:29
  • You need to manually change _"_, when you copy from here is not the same. – cpatricio Oct 27 '16 at 15:39
  • Pascal does not use double-quotes. It uses single-quotes. Did you even try to compile the code? – Martin Prikryl Oct 27 '16 at 15:49
  • thanks its worked .How to change WizardDirValue() Like {userappdata}\Myapp\file.xml – Thilanka Oct 29 '16 at 04:50
  • `ExpandConstant('{userappdata}')+'\Myapp\'+fname` – cpatricio Oct 29 '16 at 04:53
  • Is this Correct Load String From File Command--> Result := LoadStringFromFileLoadStringFromFile('{userappdata}' + '\Myapp\file.xml' + fname, fhandle); I use this But Didnt work(Code compile Without error But Didnt change data. please help me. thanks. – Thilanka Oct 30 '16 at 04:49
  • fname is an argument of sed function, so you should have "file.xml" in sed function but call sed function with "file.xml". – cpatricio Oct 30 '16 at 05:39