实际上,我只需要看看它是否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;
检查WizardForm.ComponentsList
:
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;
您还可以计算 中的元素数WizardSelectedComponents
:
function GetSelectedComponentsCount: Integer;
var
S: TStringList;
begin
S := TStringList.Create();
S.CommaText := WizardSelectedComponents(False);
Result := S.Count;
S.Free;
end;
(计算逗号会更有效,代码会稍微少一些,但很难理解。)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句