Inno Setup - 查看选择了多少组件

时间:2017-06-02 08:25:49

标签: inno-setup pascal pascalscript

实际上,我只需要查看它是1还是更多。以下是我打算如何使用它:

if [Only one component is selected] then
begin
  Result := CustomMessage('[Name of that component]');
  if IsComponentSelected('[Specific Component]') then
  begin
    if IsTaskSelected('[Task]') then
    begin
      Result := CustomMessage('[Name of that task]');
    end
  end
end
if [More than one component is selected] then
begin
  Result := 'Full Feature';// or '{#SetupSetting("AppName")}'
end;

我想我至少知道一种“解决方法”的方法,但我想知道这是否可以通过更传统的Inno方式(以及更清晰的代码)来完成。

----- -----编辑

使用Martins的最终功能回答:

function UninstallName(Value: string): string;
begin
  if GetSelectedComponentsCount = 1 then
  begin
    Result := CustomMessage(WizardSelectedComponents(False));
    if IsComponentSelected('bc2') then
    begin      
      if IsTaskSelected('bc2tp2') then
      begin
        Result := CustomMessage('bc2tp2');
      end;
    end;
    if Pos(':',Result) > 1 then
    StringChangeEx(Result, ':', ' -', False)
  end;
  if GetSelectedComponentsCount > 1 then
  begin
    Result := '{#SetupSetting("AppName")}';
  end;
end;

1 个答案:

答案 0 :(得分:2)

检查//: Playground - noun: a place where people can play import UIKit import PlaygroundSupport let view = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 400)) view.backgroundColor = UIColor.blue let button = UIButton() button.backgroundColor = UIColor.red button.frame.size = CGSize(width: 40.0, height: 20.0) button.translatesAutoresizingMaskIntoConstraints = false view.addSubview(button) // This does the trick PlaygroundPage.current.liveView = view

WizardForm.ComponentsList

您还可以计算WizardSelectedComponents中的元素数量:

function GetSelectedComponentsCount: Integer;
var
  I: Integer;
begin
  Result := 0;
  for I := 0 to WizardForm.ComponentsList.Items.Count - 1 do
  begin
    if WizardForm.ComponentsList.Checked[I] then
      Result := Result + 1;
  end;
end;

(计算逗号会更有效,代码更少,但理解起来更神秘。)