将Inno Setup自定义页面字段值保存到INI文件 [英] Save Inno Setup custom page field values to an INI file

查看:429
本文介绍了将Inno Setup自定义页面字段值保存到INI文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何读取两个页面字段值的值并将其存储到INI文件中?我使用ISTool在INI部分创建了两个密钥对.现在如何将其链接起来?

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

INI部分如下所示:

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: 

页面是这样创建的:

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



我添加了以下内容.由于某些原因,它不起作用:

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

推荐答案

这应该有效:

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

这篇关于将Inno Setup自定义页面字段值保存到INI文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆