我正在使用Inno Setup进行安装。我想密码保护卸载。所以我的计划是在安装过程中要求卸载密码,并将其保存到文件中。在卸载时,要求用户输入密码并比较密码。使用Inno Setup进行密码保护卸载
我找不到让用户在卸载时输入密码的方法,有没有办法?
我正在使用Inno Setup进行安装。我想密码保护卸载。所以我的计划是在安装过程中要求卸载密码,并将其保存到文件中。在卸载时,要求用户输入密码并比较密码。使用Inno Setup进行密码保护卸载
我找不到让用户在卸载时输入密码的方法,有没有办法?
密码保护卸载不起作用,因为用户可以简单地手动删除您的文件。这意味着在Inno Setup中确实没有内置选项来执行此操作。
如果您想要尝试此操作,则可以使用InitializeUninstall事件函数询问用户密码并在不匹配时返回False。这将中止卸载程序。
您可以在Inno Setup帮助中检查“CheckPassword”功能。
'CheckPassword'仅在安装程序中使用,不在卸载程序中使用。 – 2016-06-03 06:16:07
一些Inno Setup用户要求在卸载软件的用户可能之前要求输入密码。例如,反病毒软件可能会成为这种需求的候选者。 下面的代码显示了如何创建表单,要求输入密码,并且只有在密码正确的情况下才能卸载软件。 这种方法非常弱,很容易找到密码。所以,想要使用这种策略来保护软件免于卸载的人需要编写更安全的代码。如果用户想要卸载并且不知道密码文件可以从应用程序的文件夹中删除。在本示例中,卸载密码为removeme。
[Setup]
AppName=UninsPassword
AppVerName=UninsPassword
DisableProgramGroupPage=true
DisableStartupPrompt=true
DefaultDirName={pf}\UninsPassword
[Code]
function AskPassword(): Boolean;
var
Form: TSetupForm;
OKButton, CancelButton: TButton;
PwdEdit: TPasswordEdit;
begin
Result := false;
Form := CreateCustomForm();
try
Form.ClientWidth := ScaleX(256);
Form.ClientHeight := ScaleY(100);
Form.Caption := 'Uninstall Password';
Form.BorderIcons := [biSystemMenu];
Form.BorderStyle := bsDialog;
Form.Center;
OKButton := TButton.Create(Form);
OKButton.Parent := Form;
OKButton.Width := ScaleX(75);
OKButton.Height := ScaleY(23);
OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 50);
OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
OKButton.Caption := 'OK';
OKButton.ModalResult := mrOk;
OKButton.Default := true;
CancelButton := TButton.Create(Form);
CancelButton.Parent := Form;
CancelButton.Width := ScaleX(75);
CancelButton.Height := ScaleY(23);
CancelButton.Left := Form.ClientWidth - ScaleX(75 + 50);
CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
CancelButton.Caption := 'Cancel';
CancelButton.ModalResult := mrCancel;
CancelButton.Cancel := True;
PwdEdit := TPasswordEdit.Create(Form);
PwdEdit.Parent := Form;
PwdEdit.Width := ScaleX(210);
PwdEdit.Height := ScaleY(23);
PwdEdit.Left := ScaleX(23);
PwdEdit.Top := ScaleY(23);
Form.ActiveControl := PwdEdit;
if Form.ShowModal() = mrOk then
begin
Result := PwdEdit.Text = 'removeme';
if not Result then
MsgBox('Password incorrect: Uninstallation prohibited.', mbInformation, MB_OK);
end;
finally
Form.Free();
end;
end;
function InitializeUninstall(): Boolean;
begin
Result := AskPassword();
end;
来源: http://www.vincenzo.net/isxkb/index.php?title=Require_an_uninstallation_password
我不能找到一种方法,让用户在卸载输入密码(我试图用CreateInputQueryPage但它给错误)。如何把输入从用户卸载时? – Navaneeth 2010-04-05 12:23:08