如何在具有多个单选按钮的Inno设置中执行文件? [英] How to execute files in Inno setup with multiple radio buttons?

查看:45
本文介绍了如何在具有多个单选按钮的Inno设置中执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I have file1.exe, file2.exe and file3.exe wrapped in a single setup file using Inno so that the file# of choice is launched when user selects its associated radio button?

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

Please see the complete script I'm trying to make work. Since there is no Check flag on [Files] or any kind of procedure and listeners, upon clicking Next - all 3 files launch one after another.

===

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

推荐答案

[Run] 部分具有 Check 像所有其他条目都分成参数的其他部分一样使用parameter.在您的情况下,我将编写一个通用的检查函数,如下所示:

The [Run] section has Check parameter like all the other sections whose entries are separated into parameters do. In your case I would write a common check function like this:

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

这篇关于如何在具有多个单选按钮的Inno设置中执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆