Inno Setup - 在准备安装页面上显示自定义组件 [英] Inno Setup - Show custom components on Ready to Install page
本文介绍了Inno Setup - 在准备安装页面上显示自定义组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将我的组件和从 ini 文件中选择的用户添加到 准备安装 页面.这甚至可能吗?
它应该看起来像这个例子:
这是我的ini文件:
[用户]用户 1=程序 1,程序 3用户 2=程序 1,程序 2用户 3=程序 1,程序 3用户 4=程序 1,程序 2
还有我的脚本:
[文件]来源:TESTSoftwarex64Program_1";目标目录:{app}Program_1";标志:忽略版本递归子目录;检查: ShouldInstallProgram('Program1')来源:TESTSoftwarex64Program_2";目标目录:{app}Program_2";标志:忽略版本递归子目录;检查: ShouldInstallProgram('Program2')来源:TESTSoftwarex64Program_3";目标目录:{app}Program_3";标志:忽略版本递归子目录;检查: ShouldInstallProgram('Program3')
[代码]函数应该安装程序(程序名称:字符串):布尔值;变量用户名:字符串;ProgramsStr:字符串;程序:TStringList;开始用户名 := WizardSetupType(False);ProgramsStr :=GetIniString('Users', UserName, '', ExpandConstant('{src}UserPrograms.ini'));程序:= TStringList.Create;Programs.CommaText := ProgramsStr;结果 := (Programs.IndexOf(ProgramName) >= 0);程序.免费;结尾;
解决方案
实现UpdateReadyMemo
事件函数.请参阅
I would like to add my components and the selected user from the ini file to the Ready to Install page. Is this even possible?
It should look like this example:
This is my ini file:
[Users]
user1=Program1,Program3
user2=Program1,Program2
user3=Program1,Program3
user4=Program1,Program2
And my script:
[Files]
Source: "TEST Softwarex64Program_1"; DestDir: "{app}Program_1";
Flags: ignoreversion recursesubdirs; Check: ShouldInstallProgram('Program1')
Source: "TEST Softwarex64Program_2"; DestDir: "{app}Program_2";
Flags: ignoreversion recursesubdirs; Check: ShouldInstallProgram('Program2')
Source: "TEST Softwarex64Program_3"; DestDir: "{app}Program_3";
Flags: ignoreversion recursesubdirs; Check: ShouldInstallProgram('Program3')
[Code]
function ShouldInstallProgram(ProgramName: string): Boolean;
var
UserName: string;
ProgramsStr: string;
Programs: TStringList;
begin
UserName := WizardSetupType(False);
ProgramsStr :=
GetIniString('Users', UserName, '', ExpandConstant('{src}UserPrograms.ini'));
Programs := TStringList.Create;
Programs.CommaText := ProgramsStr;
Result := (Programs.IndexOf(ProgramName) >= 0);
Programs.Free;
end;
解决方案
Implement UpdateReadyMemo
event function. See Add text to 'Ready Page' in Inno Setup
Something like this:
function GetUserName: string;
begin
Result := WizardSetupType(False);
end;
function GetProgramsToInstall: TStrings;
begin
Result := TStringList.Create;
Result.CommaText :=
GetIniString('Users', GetUserName, '', ExpandConstant('{src}UserPrograms.ini'));
end;
function ShouldInstallProgram(ProgramName: string): Boolean;
var
Programs: TStrings;
begin
Programs := GetProgramsToInstall;
Result := (Programs.IndexOf(ProgramName) >= 0);
Log(Format('Program [%s] - %d', [ProgramName, Result]));
Programs.Free;
end;
procedure AddToReadyMemo(var Memo: string; Info, NewLine: string);
begin
if Info <> '' then Memo := Memo + Info + Newline + NewLine;
end;
function UpdateReadyMemo(
Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo,
MemoGroupInfo, MemoTasksInfo: String): String;
var
Programs: TStrings;
I: Integer;
begin
AddToReadyMemo(Result, MemoUserInfoInfo, NewLine);
AddToReadyMemo(Result, MemoDirInfo, NewLine);
AddToReadyMemo(Result, MemoTypeInfo, NewLine);
AddToReadyMemo(Result, MemoComponentsInfo, NewLine);
AddToReadyMemo(Result, MemoGroupInfo, NewLine);
AddToReadyMemo(Result, MemoTasksInfo, NewLine);
Result :=
Result +
'Selected user:' + NewLine +
Space + GetUserName + NewLine + NewLine;
Programs := GetProgramsToInstall;
if Programs.Count > 0 then
begin
Result := Result + 'Components:' + NewLine;
for I := 0 to Programs.Count - 1 do
Result := Result + Space + Programs[I] + NewLine;
end;
Programs.Free;
end;
这篇关于Inno Setup - 在准备安装页面上显示自定义组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文