Passwords Inno设置:如何仅在组件“打开”时创建密码向导页;X";挑选出来的

Passwords Inno设置:如何仅在组件“打开”时创建密码向导页;X";挑选出来的,passwords,inno-setup,pascal,password-protection,Passwords,Inno Setup,Pascal,Password Protection,有人能帮我保护选择组或组件吗 例如 If ('Readme.txt').selected or ('compact').selected = True then begin "Password wizard page"; else result := true; end; 类似于此工作脚本的内容:p function CheckPassword(Password: String): Boolean; begin result := false; if (Password='componen

有人能帮我保护选择组或组件吗

例如

If ('Readme.txt').selected or ('compact').selected = True then
begin "Password wizard page";
else
result := true;
end;
类似于此工作脚本的内容:p

function CheckPassword(Password: String): Boolean;
begin
 result := false;
 if (Password='component') or (Password='type') then
   result := true;
end;

我不确定我是否完全理解你的问题,但也许这有帮助。以下是一些只需添加到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;
函数NextButtonClick(CurPageID:Integer):布尔;
开始
结果:=真;
如果CurPageID=PasswordPage.ID,则开始
//如果密码错误,请停留在此页面
如果PasswordPage.Edits[0]。文本“我的密码”,则开始
MsgBox(设置消息(msgIncorrectPassword),mbError,MB_OK);
结果:=假;
结束;
结束;
结束;