如何通过名称查找组件索引?

BeG*_*GiN 2 inno-setup

为什么我不能使用以下行获取我的组件索引之一:

WizardForm.ComponentsList.FindComponent('core').ComponentIndex
Run Code Online (Sandbox Code Playgroud)

如果我错了,有人可以为我指出一种获取组件索引的方法吗?

BeG*_*GiN 5

目前,无法ComponentsList通过 componentName参数在 中找到组件项的索引。该Name参数存储在TSetupComponentEntry结构,这是由持有ComponentsList.ItemObject[i]对象集合,但你不能访问它由于缺乏失踪Inno Setup的Pascal脚本指针支持。

在 中唯一标识组件的唯一方法ComponentsList是通过其Description参数。要通过在 中的描述查找某个组件的索引ComponentsList,您可以使用:

[Components]
Name: "mycomponent"; Description: "Component description"; Types: full

[Code]
...
var
  ItemIndex: Integer;
begin
  ItemIndex := WizardForm.ComponentsList.Items.IndexOf('Component description');
  ...
end;
Run Code Online (Sandbox Code Playgroud)