4
votes

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
1
What do you mean: nothing works? Aren't you getting any values? Does your condition not work? Please post some code so we can see what you're doing. - Thorsten Dittmar
I paste code into first post. GetIniString don't get any values. Condition works properly. - Vertius
Just for the sake of completeness: This is not a forum, so there's nothing like a "post". You ask a question, others provide answers. When we ask for more details, we expect you to edit your question and not to "add a new post". Answers are sorted by their votes, so ultimately, another "answer" posted by you will end up at the bottom of the list. - Thorsten Dittmar
I've edited my answer. Please check whether this works. - Thorsten Dittmar

1 Answers

8
votes

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');