Nav*_*eth 6 passwords inno-setup uninstallation
我正在使用Inno Setup制作安装程序.我想用密码保护卸载.所以我的计划是在安装过程中要求卸载密码,并将其保存到文件中.卸载时,请求用户输入密码并比较密码.
在卸载时我找不到让用户输入密码的方法,有没有?
某些 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;
Run Code Online (Sandbox Code Playgroud)
来源: http://www.vincenzo.net/isxkb/index.php? title=Require_an_uninstallation_password
密码保护卸载不起作用,因为用户可以简单地手动删除您的文件。这意味着 Inno Setup 中确实没有内置选项来执行此操作。
如果您想尝试此操作,您可以使用 InitializeUninstall 事件函数来询问用户密码,并在不匹配时返回 False。这将中止卸载程序。
归档时间: |
|
查看次数: |
1874 次 |
最近记录: |