gpt4 book ai didi

inno-setup - 如何在 Inno Setup 中安装期间为可选文件添加复选框?

转载 作者:行者123 更新时间:2023-12-04 04:44:53 31 4
gpt4 key购买 nike

我正在尝试在我的自定义页面中制作一个自定义复选框(因为它是一个单页安装程序),只需要一个没有对话框或任何东西的复选框,我试图编译的安装程序非常线性和简单。

我要绑定(bind)FILE3.EXE以这种方式在复选框上:如果选中复选框,则将文件(FILE3.EXE)复制到 DestDir ,否则如果未选中复选框,则在安装过程中跳过文件 (FILE3.EXE)。

这是我使用的代码,显然复选框代码丢失了,因为我无法做到这一点

[Files]
Source: FILE1.EXE; DestDir: {app};
Source: FILE2.EXE; DestDir: {app};
Source: FILE3.EXE; DestDir: {app}; //OPTIONAL

[Code]
procedure ExitProcess(uExitCode: UINT);
external 'ExitProcess@kernel32.dll stdcall';

var
MainPage : TWizardPage;
FolderToInstall : TEdit;
InstallLocation : String;

procedure CancelClick(Sender: TObject);
begin
if ExitSetupMsgBox then
begin
ExitProcess(0);
end;
end;

procedure BrowseClick(Sender : TObject);
var
Dir : String;

begin
Dir := FolderToInstall.Text;
if BrowseForFolder('Browse',Dir,false) then
FolderToInstall.Text := Dir;
WizardForm.DirEdit.Text := Dir;
end;

procedure InitializeWizard();
var
LabelFolder : TLabel;
begin
MainPage := CreateCustomPage(wpWelcome,'','');
LabelFolder := TLabel.Create(MainPage);
LabelFolder.Parent := WizardForm;
LabelFolder.Top := 164;
LabelFolder.Left := 6;
LabelFolder.Caption := 'Directory:'

FolderToInstall := TEdit.Create(MainPage);
FolderToInstall.Parent := WizardForm;
FolderToInstall.Top := 182;
FolderToInstall.Left := 85;
FolderToInstall.Width := 380;
FolderToInstall.Text := WizardDirValue;
FolderToInstall.ReadOnly := True;
end;

最佳答案

您不必为此手动创建复选框。让用户选择安装什么的标准方法是使用 [Types][Components]脚本文件的部分。

看看Components.iss位于 Inno Setup 安装文件夹\examples 中的脚本。

; -- Components.iss --
; Demonstrates a components-based installation.

; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output

[Types]
Name: "full"; Description: "Full installation"
Name: "compact"; Description: "Compact installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Components]
Name: "program"; Description: "Program Files"; Types: full compact custom; Flags: fixed
Name: "help"; Description: "Help File"; Types: full
Name: "readme"; Description: "Readme File"; Types: full
Name: "readme\en"; Description: "English"; Flags: exclusive
Name: "readme\de"; Description: "German"; Flags: exclusive

[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Components: program
Source: "MyProg.chm"; DestDir: "{app}"; Components: help
Source: "Readme.txt"; DestDir: "{app}"; Components: readme\en; Flags: isreadme
Source: "Readme-German.txt"; DestName: "Liesmich.txt"; DestDir: "{app}"; Components: readme\de; Flags: isreadme

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

在运行时,安装程​​序会在向导中显示此对话框:

Components dialog

关于inno-setup - 如何在 Inno Setup 中安装期间为可选文件添加复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13502346/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com