Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup Read value from .ini

Tags:

ini

inno-setup

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

//edit Here is a 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
like image 646
Vertius Avatar asked Feb 21 '23 02:02

Vertius


1 Answers

There are Pascal Script functions like GetIniInt or GetIniString you can use to read from an ini file. See this reference.

I'd like to note that I wrote this reply before the OP changed his question to tell us he'd already tried the GetIniString and ReadIni functions. So yes: I did read the question before writing this answer :-)

From the code you've posted I can see you're trying to read an ini file from the Program Files folder. This, however, only works when using the ExpandConstant function, so it should read

a:=GetIniString('Select', 'First', 'false', ExpandConstant('{pf}') + '\SP_Settings.ini');
b:=GetIniString('Select', 'Should', 'true', ExpandConstant('{pf}') + '\SP_Settings.ini');
like image 164
Thorsten Dittmar Avatar answered Feb 26 '23 16:02

Thorsten Dittmar