首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Inno-setup:将用户的所有选择存储在INI文件中

Inno-setup:将用户的所有选择存储在INI文件中
EN

Stack Overflow用户
提问于 2012-01-05 23:37:24
回答 1查看 2.3K关注 0票数 0

我希望将用户在安装过程中所做的所有选择(或者默认值,如果用户没有更改它们)存储在一个.INI文件中。我知道命令行选项/LOADINF和/SAVEINF,但我希望拥有类似的功能,而不依赖于命令行。这将用于在重新安装的情况下保留设置,但也用于定义一组设置(由管理员定义),以便在跨分散办公室的多个安装中使用。

谢谢你的帮助

EN

回答 1

Stack Overflow用户

发布于 2012-01-06 01:08:59

做你想做的事情是可能的。不过,您的代码部分需要相当多的代码。几年前我也做过类似的事情,但我只读了INI。我从来没有写过INI文件。您应该能够使用SetIni* (SetIniString、SetIniBool等)对其进行写入。函数。您可以使用GetIni*函数读取INI文件。这是我收集的一个快速示例,它给出了一个想法:

代码语言:javascript
复制
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"

[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={{4CCA332F-C69B-48DF-93B4-145EB88A1BCB}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={code:GetDefaultDir}
DefaultGroupName={#MyAppName}
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\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: nowait postinstall skipifsilent

[Code]
var 
FinishedInstall : boolean;

function GetDefaultDir(def: string): string;
var
sInstallPath : string;
bRes : boolean;

begin
  sInstallPath := GetIniString('Common', 'TargetDir', ExpandConstant('{pf}') + '\myApp', ExpandConstant('{src}') + '\myappsetup.INI');
  Result := sInstallPath;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
     FinishedInstall := True;
end;

procedure DeinitializeSetup();
var
bIni : boolean;
begin
if FinishedInstall then
  bIni := SetIniString('Common', 'TargetDir',ExpandConstant('{app}'), ExpandConstant('{app}') + '\myappsetup.INI');
end;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8745174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档