InnoSetup非常新,但我找不到任何关于此的文档。我想实现一个条件,如果用户已经安装了特定组件,它将不允许他们安装另一个特定组件。
例如:如果Bob先前已经安装了ComponentA,并且绑定安装ComponentB,它将向我们发出错误警告“当ComponentA当前安装时无法安装ComponentB”
这是我到目前为止所提出的:
procedure CurPageChanged(CurPageID: Integer);
var
Value: string;
UninstallKey: string;
begin
UninstallKey := 'Software\Microsoft\Windows\CurrentVersion\Uninstall\' +
ExpandConstant('{#SetupSetting("AppId")}') + '_is1';
Result := (RegQueryStringValue(HKLM, UninstallKey, 'Inno Setup: Selected Components', Value) or
RegQueryStringValue(HKCU, UninstallKey, 'Inno Setup: Selected Components', Value)) and (Value <> '');
if CurPageID = wpSelectComponents then
if Result = WizardForm.ComponentsList.ItemCaption[1] then
begin
WizardForm.ComponentsList.Checked[1] := False;
WizardForm.ComponentsList.ItemEnabled[1] := True;
WizardForm.ComponentsList.Checked[2] := False;
WizardForm.ComponentsList.ItemEnabled[2] := False;
WizardForm.ComponentsList.Checked[3] := False;
WizardForm.ComponentsList.Enabled[3] := True;
end;
end;
end;
我知道我没有完全适合所选组件的注册表查询..我觉得我很接近。问题是,结果可能包含多个组件。喜欢(苹果,橙子,芒果),但如果只是“芒果”,我希望这句话仍然是真的。
答案 0 :(得分:0)
认为你可以用另一种方式做到这一点:
使用标志:
exclusive
示例:
[Types]
Name: "full"; Description: "Full"; Flags: iscustom
[Components]
Name: "connect"; Description: "Mainsection"; Types: "full" ;Flags: fixed
Name: "connect\compA"; Description: "ComponentA"; Types: "full"; Flags: exclusive
Name: "connect\compB"; Description: "ComponentB"; Flags: exclusive
[Files]
Source: "srcpath"; DestDir: "dirpath"; Components: connect\compA
Source: "srcpath"; DestDir: "dirpath"; Components: connect\compB
It looks like this
所以如果&#34; Bob&#34;想要选择componenB他不能使用ComponentA而不自动取消选择componentB
现在如果&#34; Bob&#34;已安装ComponentA并想安装ComponentB,你不希望安装这两个组件你需要使用installdelete
示例:
[InstallDelete]
Type: filesandordirs; Name: "dirpath\compA"; Components: connect\compB;
Type: filesandordirs; Name: "dirpath\compB"; Components: connect\compA;
我希望这会有所帮助