views:

31

answers:

2

Hi,

How do I read and store the values of two form field values to an INI file? I created two key pairs at the INI section using ISTool. Now how do I link this up?

I am assuming I should write some Pascal script in here, but don't know exactly what, yet

{ AuthForm_NextkButtonClick }

function AuthForm_NextButtonClick(Page: TWizardPage): Boolean;
begin
  Result := True;
end;

The INI Section looks like this:

[INI]
Filename: {app}\prefs.ini; Section: AUTH; Key: USERNAME; String: 
Filename: {app}\prefs.ini; Section: AUTH; Key: PASSWORD; String: 

Page is created like this:

  AuthPage := CreateInputQueryPage(wpWelcome,
    'Account Information', 'Please enter your Account Information',
    '');
  AuthPage.Add('Username:', False);
  AuthPage.Add('Password:', True);

EDIT:

I made the following additions. It doesn't work for some reason:

SetIniString('AUTH', 'USERNAME', AuthPage.Values[0], '{app}\prefs.ini')
SetIniString('AUTH', 'PASSWORD', AuthPage.Values[1], '{app}\prefs.ini')
A: 

I believe you need to write ExpandConstant('{app}\prefs.ini') to expand the {app} constant.

Andreas Rejbrand
+1  A: 

This should work:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{82C8C949-44A8-49C4-8CED-8DD0ACD0DCCF}
AppName=My Program
AppVerName=My Program 1.5
AppPublisher=My Company, Inc.
AppPublisherURL=http://www.example.com/
AppSupportURL=http://www.example.com/
AppUpdatesURL=http://www.example.com/
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

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

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\util\innosetup\5.3.7\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion

; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
Name: "{commondesktop}\My Program"; Filename: "{app}\MyProg.exe"; Tasks: desktopicon

[Run]
Filename: "{app}\MyProg.exe"; Description: "{cm:LaunchProgram,My Program}"; Flags: nowait postinstall skipifsilent

[INI]
Filename: {app}\prefs.ini; Section: AUTH; Key: USERNAME; String: {code:GetUserName}
Filename: {app}\prefs.ini; Section: AUTH; Key: PASSWORD; String: {code:GetPassword}


[code]
var
AuthPage : TInputQueryWizardPage;

procedure InitializeWizard;
begin
AuthPage := CreateInputQueryPage(wpWelcome,
    'Account Information', 'Please enter your Account Information',
    '');
  AuthPage.Add('Username:', False);
  AuthPage.Add('Password:', True);
end;

function AuthForm_NextButtonClick(Page: TWizardPage): Boolean;
begin
  Result := True;
end;

function GetUserName(Param: String): string;
begin
result := AuthPage.Values[0];
end;

function GetPassword(Param: String): string;
begin
result := AuthPage.Values[1];
end;
mirtheil
It did. I Liked this very much: "{code:GetUserName}" Thanks!
Sheriff Md