1

如何使用 Inno 将 file1.exe、file2.exe 和 file3.exe 包装在单个安装文件中,以便在用户选择其关联的单选按钮时启动选择的文件#?

请查看我正在尝试制作的完整脚本。由于 [Files] 或任何类型的过程和侦听器上没有 Check 标志,因此单击 Next - 所有 3 个文件一个接一个地启动。

===

[Setup]   
CreateAppDir=no   
OutputDir=C:\Single-Exe   
OutputBaseFilename=setup   
Compression=lzma   
SolidCompression=yes   
DisableWelcomePage=True   
DisableReadyPage=True   
DisableFinishedPage=True   
Uninstallable=no

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

[Files]
Source: file1.exe; DestDir: {app};
Source: file2.exe; DestDir: {app};
Source: file3.exe; DestDir: {app};

[Run]
Filename: {app}\file1.exe; Flags: hidewizard runhidden 32bit; WorkingDir: {localappdata}
Filename: {app}\file2.exe; Flags: hidewizard runhidden 32bit; WorkingDir: {localappdata}
Filename: {app}\file3.exe; Flags: hidewizard runhidden 64bit; WorkingDir: {localappdata}

[Code]
const
  FileOneDesc =
    'Select if you want to run File1.exe';
  FileTwoDesc =
    'Select if you want to run File2.exe';
  FileThreeDesc =
    'Select if you want to run File3.exe';

var
  FileOneButton: TNewRadioButton;
  FileTwoButton: TNewRadioButton;
  FileThreeButton: TNewRadioButton;

procedure InitializeWizard;
var                                                 
  CustomPage: TWizardPage;
  FileOneDesclabel: TLabel;
  FileTwoDesclabel: TLabel;
  FileThreeDesclabel: TLabel;

begin
  CustomPage := CreateCustomPage(wpWelcome, 'Multiple executable pre-launch wizard', '');
  FileOneButton := TNewRadioButton.Create(WizardForm);
  FileOneButton.Parent := CustomPage.Surface;
  FileOneButton.Top := 16;     
  FileOneButton.Width := CustomPage.SurfaceWidth;
  FileOneButton.Font.Style := [fsBold];
  FileOneButton.Font.Size := 9;
  FileOneButton.Caption := 'Run File #1'
  FileOneDescLabel := TLabel.Create(WizardForm);
  FileOneDescLabel.Parent := CustomPage.Surface;
  FileOneDescLabel.Left := 8;
  FileOneDescLabel.Top := FileOneButton.Top + FileOneButton.Height + 8;
  FileOneDescLabel.Width := CustomPage.SurfaceWidth;
  FileOneDescLabel.Height := 40;
  FileOneDescLabel.AutoSize := False;
  FileOneDescLabel.Wordwrap := True;
  FileOneDescLabel.Caption := FileOneDesc;

  FileTwoButton := TNewRadioButton.Create(WizardForm);
  FileTwoButton.Parent := CustomPage.Surface;
  FileTwoButton.Top := FileOneDesclabel.Top + FileOneDesclabel.Height + 8;
  FileTwoButton.Width := CustomPage.SurfaceWidth;
  FileTwoButton.Font.Style := [fsBold];
  FileTwoButton.Font.Size := 9;
  FileTwoButton.Caption := 'Run File #2'
  FileTwoDescLabel := TLabel.Create(WizardForm);
  FileTwoDescLabel.Parent := CustomPage.Surface;
  FileTwoDescLabel.Left := 8;
  FileTwoDescLabel.Top := FileTwoButton.Top + FileTwoButton.Height + 8;
  FileTwoDescLabel.Width := CustomPage.SurfaceWidth;
  FileTwoDescLabel.Height := 40;
  FileTwoDescLabel.AutoSize := False;
  FileTwoDescLabel.Wordwrap := True;
  FileTwoDescLabel.Caption := FileTwoDesc;

  FileThreeButton := TNewRadioButton.Create(WizardForm);
  FileThreeButton.Parent := CustomPage.Surface;
  FileThreeButton.Top := FileTwoDesclabel.Top + FileTwoDesclabel.Height + 10;
  FileThreeButton.Width := CustomPage.SurfaceWidth;
  FileThreeButton.Font.Style := [fsBold];
  FileThreeButton.Font.Size := 9;
  FileThreeButton.Caption := 'Run File #3'
  FileThreeDescLabel := TLabel.Create(WizardForm);
  FileThreeDescLabel.Parent := CustomPage.Surface;
  FileThreeDescLabel.Left := 8;
  FileThreeDescLabel.Top := FileThreeButton.Top + FileThreeButton.Height + 8;
  FileThreeDescLabel.Width := CustomPage.SurfaceWidth;
  FileThreeDescLabel.Height := 40;
  FileThreeDescLabel.AutoSize := False;
  FileThreeDescLabel.Wordwrap := True;
  FileThreeDescLabel.Caption := FileThreeDesc;
  end;
4

1 回答 1

3

[Run]部分具有Check参数,就像其条目被分成参数的所有其他部分一样。在你的情况下,我会写一个像这样的通用检查函数:

[Run]
Filename: {app}\file1.exe; Flags: hidewizard runhidden 32bit; WorkingDir: {localappdata}; Check: ShouldRunItem(1)
Filename: {app}\file2.exe; Flags: hidewizard runhidden 32bit; WorkingDir: {localappdata}; Check: ShouldRunItem(2)
Filename: {app}\file3.exe; Flags: hidewizard runhidden 64bit; WorkingDir: {localappdata}; Check: ShouldRunItem(3)
...

[Code]
function ShouldRunItem(Value: Integer): Boolean;
begin
  Result := False;
  case Value of
    1: Result := FileOneButton.Checked;
    2: Result := FileTwoButton.Checked;
    3: Result := FileThreeButton.Checked;
  end;
end;
于 2013-08-06T09:34:51.390 回答