如何在创新安装有多个单选按钮执行文件?(How to execute files in Inno s

2019-10-18 11:26发布

我怎样才能有file1.exe,file2.exe和file3.exe包裹在利用创新科技,这样,当用户选择其关联的单选按钮选择文件#启动一个安装文件?

请看到我努力使工作完整的脚本。 由于是在[文件]无校验标志或任何种类的程序和听众,在单击下一步 - 所有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;

Answer 1:

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


文章来源: How to execute files in Inno setup with multiple radio buttons?
标签: inno-setup