簡體   English   中英

如何只允許在InnoSetup中安裝特定組件?

[英]How to allow to only install specific components in InnoSetup?

所以問題是:我在這里問了一個問題: 如何只允許安裝到特定的文件夾?

如何修改它,例如,我有3個文件要安裝,其中2個是可選的,如果存在某個文件/文件夾,應該只能安裝。 如果條件不滿足,我想在列表中選擇它們的灰色選項?

先感謝您。 索爾特

我會嘗試做以下事情。 它將訪問組件列表項,通過索引禁用和取消選中它們,從[Components]部分的順序開始從0開始的數字是多少。 默認情況下啟用沒有fixed標志的項目(如本例所示),因此您需要檢查是否未滿足條件。 您也可以查看這篇文章的commented version

[Components]
Name: Component1; Description: Component 1
Name: Component2; Description: Component 2
Name: Component3; Description: Component 3

[code]
procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectComponents then
    if not SomeCondition then
    begin
      WizardForm.ComponentsList.Checked[1] := False;
      WizardForm.ComponentsList.ItemEnabled[1] := False;
      WizardForm.ComponentsList.Checked[2] := False;
      WizardForm.ComponentsList.ItemEnabled[2] := False;
    end;
end;

上述解決方案至少有一個缺點。 該指數可能從原來的順序被打亂[Components]節當您將ComponentsList.Sorted為True。 如果你不這樣做
使用它,它可能足以使用上面的代碼,如果是的話,那就更復雜了。

沒有簡單的方法來獲取組件名稱(它在內部存儲為每個項目的ItemObjectTSetupComponentEntry對象),只有描述,所以這里是另一種方法來做同樣的事情,區別是項目索引被搜索他們的描述指定。

procedure CurPageChanged(CurPageID: Integer);
var
  Index: Integer;
begin
  if CurPageID = wpSelectComponents then
    if not SomeCondition then
    begin
      Index := WizardForm.ComponentsList.Items.IndexOf('Component 2');
      if Index <> -1 then
      begin
        WizardForm.ComponentsList.Checked[Index] := False;
        WizardForm.ComponentsList.ItemEnabled[Index] := False;
      end;
      Index := WizardForm.ComponentsList.Items.IndexOf('Component 3');
      if Index <> -1 then
      begin
        WizardForm.ComponentsList.Checked[Index] := False;
        WizardForm.ComponentsList.ItemEnabled[Index] := False;
      end;
    end;
end;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM