在 Windows 中尝试卸载我的 java 应用程序时要求输入密码
Ask for password when try to uninstall my java application in Windows
我已经为 Windows 制作了 java 应用程序的安装程序。在 Windows 安装后一切正常。现在我想添加一项功能,当我尝试卸载我的应用程序时 要求输入密码 没有密码肯定无法卸载它。
我想知道的另一件事是,我是否需要制作一个单独的卸载程序,或者我是否可以在我的安装程序本身中添加这些功能?
如有任何帮助,我们将不胜感激。
P.S. 这里我的目标是 Windows OS 安装应用程序。
In short, I want that if someone tries to uninstall my application, he prompted for a password and if he enters the right password then
and then he can able to uninstall it.
I don't know to achieve above want, whether I need to change my
installer or I need to create a custom uninstaller.
终于,经过如此多的努力,我找到了一些很好的资源,可以向我解释所有的问题。
在 Inno Setup pascal 脚本中,我可以修改一些代码来实现密码保护,如下所示:
[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;
信息来源:this post
我已经为 Windows 制作了 java 应用程序的安装程序。在 Windows 安装后一切正常。现在我想添加一项功能,当我尝试卸载我的应用程序时 要求输入密码 没有密码肯定无法卸载它。
我想知道的另一件事是,我是否需要制作一个单独的卸载程序,或者我是否可以在我的安装程序本身中添加这些功能?
如有任何帮助,我们将不胜感激。
P.S. 这里我的目标是 Windows OS 安装应用程序。
In short, I want that if someone tries to uninstall my application, he prompted for a password and if he enters the right password then and then he can able to uninstall it.
I don't know to achieve above want, whether I need to change my installer or I need to create a custom uninstaller.
终于,经过如此多的努力,我找到了一些很好的资源,可以向我解释所有的问题。
在 Inno Setup pascal 脚本中,我可以修改一些代码来实现密码保护,如下所示:
[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;
信息来源:this post