Inno Setup:仅当组件“X”存在时如何创建密码向导页面已选择

发布于 2024-09-14 03:57:19 字数 382 浏览 3 评论 0原文

任何人都可以帮助我保护选择组或组件。

例如,

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;

Can anyone help me to protect a selection group or component.

For examples

If ('Readme.txt').selected or ('compact').selected = True then
begin "Password wizard page";
else
result := true;
end;

Something like that to this working script :P

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街道布景 2024-09-21 03:57:19

我不确定我完全理解你的问题,但这也许有帮助。这里有几个函数,您只需添加到 Components.iss 示例的 [code] 部分,其中一个组件(“help”)只能是当用户输入正确的密码时安装。

由于您稍后在安装过程中需要密码,而且并非总是需要密码,因此您不能使用标准设置密码页面。您将创建自己的页面并将其插入到组件选择页面之后:

[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;

I'm not sure I completely understood your question, but maybe this helps. Here are a few functions you only need to add to the [code] section of the Components.iss sample, and one of the components ("help") can only be installed when the user enters the correct password.

Since you need the password later in the installation, and not always, you can not use the standard setup password page. You will instead create your own page and insert it after the components selection page:

[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;

Note that this uses the translated password caption, you may need to make the other three strings translatable as well.

Next you will need to hide that page if the user has not selected the component for installation:

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;

Finally you need to check the password, and prevent the user from going to the next page if the password is wrong:

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文