Inno Setup Read value from .ini

I want to read a value from a .ini file. Then write the condition - if this value is "1" then do sth (do action). I tried getinistring but I didn't get any values ​​(just show the default). And I don't know how to implement readini in my code below. Thanks for any help, IS Beginner :)

// edit Here's the code:

#include ReadReg(HKEY_LOCAL_MACHINE,'Software\Sherlock Software\InnoTools\Downloader','ScriptPath','');
#include ReadReg(HKEY_LOCAL_MACHINE,'Software\Sherlock Software\InnoTools\Tray','ScriptPath','');

[Languages]
Name: english; MessagesFile: compiler:Default.isl

[Code]
function isxdl_Download(hWnd: Integer; URL, Filename: AnsiString): Integer;
external 'isxdl_Download@files:isxdl.dll stdcall';
function isxdl_SetOption(Option, Value: AnsiString): Integer;
external 'isxdl_SetOption@files:isxdl.dll stdcall';
var
a :string;
b :string;

//Downloading a component depending on component choice in another setup(read from .ini)
procedure CurStepChanged(CurStep: TSetupStep);
begin
a:=GetIniString('Select', 'First', 'false', '{pf}/SP_Settings.ini');
b:=GetIniString('Select', 'Should', 'true', {pf}\SP_Settings.ini');

begin
if CompareStr(a,b)=0 then
  if CurStep=ssInstall then begin
      isxdl_SetOption('title', 'File Download');
      isxdl_SetOption('label', 'Download');
      isxdl_SetOption('description', 'Setup is downloading a file.');
      isxdl_Download(0,'url', ExpandConstant('{app}\x.rar'));   
      end;      
end;
end;

[Files]
Source: C:\Documents and Settings\user\Pulpit\XML\Project\isxdl.dll; DestDir: {tmp}; Flags: dontcopy

      

+3


source to share


1 answer


There are Pascal Script functions like GetIniInt

or GetIniString

that you can use to read from an ini file. See this link .

I would like to point out that I wrote this answer before the OP modified his question to let us know that he already tried functions GetIniString

and ReadIni

. So yes: I read the question before writing this answer :-)



From the code you posted I can see that you are trying to read an INI file from the Program Files folder. This, however, only works when using a function ExpandConstant

, so it should read

a:=GetIniString('Select', 'First', 'false', ExpandConstant('{pf}') + '\SP_Settings.ini');
b:=GetIniString('Select', 'Should', 'true', ExpandConstant('{pf}') + '\SP_Settings.ini');

      

+6


source







All Articles