0

我应该如何修改我的代码,以便让用户确定第二个目录的路径(脚本中 java 的路径)

我在模式下尝试之前使用了这个命令:

mysetup.exe /DIR="C:\test"

安装路径 第二路径 以及如何让用户选择其中一个 Component1 或 component2 或两者。 选择要安装的组件

#define AppName "My App"
[Setup]
AppName={#AppName}
AppVersion=1
DefaultDirName={code:getInstallDir}\{#AppName}
;DefaultDirName={pf}\My App
DisableDirPage=yes

[Files]

[Code]

#include 'System.iss'
var
  Page: TInputDirWizardPage;
  UsagePage: TInputOptionWizardPage;

function InputDirPageNextButtonClick(Sender: TWizardPage): Boolean;
begin
  { Use the first path as the "destination path" }
  WizardForm.DirEdit.Text := Page.Values[0];
  Result := True;
end;

procedure InitializeWizard;
begin
  Page := CreateInputDirPage(wpWelcome,
    'Destination', '',
    'Where should App be installed?',
    False, 'New Folder');

  Page.Add('App path');
  Page.Values[0] := WizardForm.DirEdit.Text;
 
  UsagePage := CreateInputOptionPage(wpWelcome,
    'Installation', 'choose component',
    'please choose one!:',
    False, False);
  UsagePage.Add('Component1');
  UsagePage.Add('Component2');

  Page.OnNextButtonClick := @InputDirPageNextButtonClick;
  Page := CreateInputDirPage(wpSelectDir,
    'Java path', '',
    'please specify Java Folder:', False, '');

  Page.Add('Java');

  Page.OnNextButtonClick := @InputDirPageNextButtonClick;
end;
4

1 回答 1

0

如果我理解您的问题:您正在寻找一种方法来使用自定义命令行参数来填充自定义目录页面上的目录值。这是一种方法:

[Code]
var
  CustomPage: TInputDirWizardPage;
  CustomPath: string;

function InitializeSetup(): Boolean;
begin
  result := true;
  CustomPath := ExpandConstant('{param:CustomPath}');
end;

procedure InitializeWizard();
begin
  CustomPage := CreateInputDirPage(wpSelectDir,
    'Select Custom Path',
    'What custom path do you want?',
    'Select a directory.',
    false,
    '');
  CustomPage.Add('Custom path:');
  CustomPage.Values[0] := CustomPath;
end;

在您的[Code]部分中,使用参数运行安装程序/CustomPath="directory name"会将表单上的值设置为命令行中的参数。

于 2020-06-29T22:15:24.553 回答