我不确定我是否完全理解您的问题,但也许这会有所帮助。以下是您只需添加到Components.iss[code]
示例部分的几个功能,其中一个组件(“帮助”)只有在用户输入正确密码时才能安装。
由于您在安装后需要密码,而且并非总是如此,因此您不能使用标准设置密码页面。相反,您将创建自己的页面并将其插入到组件选择页面之后:
[Code]
var
PasswordPage: TInputQueryWizardPage;
procedure InitializeWizard();
begin
PasswordPage := CreateInputQueryPage(wpSelectComponents,
'Your caption goes here',
'Your description goes here',
'Your subcaption goes here');
PasswordPage.Add(SetupMessage(msgPasswordEditLabel), True);
end;
请注意,这使用了翻译后的密码标题,您可能还需要使其他三个字符串也可翻译。
接下来,如果用户尚未选择要安装的组件,您将需要隐藏该页面:
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := False;
if PageID = PasswordPage.ID then begin
// show password page only if help file is selected for installation
Result := not IsComponentSelected('help');
end;
end;
最后需要检查密码,如果密码错误,防止用户进入下一页:
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if CurPageID = PasswordPage.ID then begin
// stay on this page if password is wrong
if PasswordPage.Edits[0].Text <> 'my-secret-password' then begin
MsgBox(SetupMessage(msgIncorrectPassword), mbError, MB_OK);
Result := False;
end;
end;
end;