Inno Setup - 创建一个复选框以选择性地删除卸载程序自定义页面中的文件
Inno Setup - Create a checkbox to optionally delete files in a custom page at uninstaller
我使用以下代码为卸载程序创建了自定义页面: 我想创建一个复选框,允许我有选择地删除自定义页面中的某些文件(在卸载过程之前)。我正在尝试使用此代码:
NewCheckBox1 := TNewCheckBox.Create(UninstallProgressForm);
with NewCheckBox1 do
begin
Parent := UninstallfirstPage;
Left := NewStaticText1.Left;
Top := NewStaticText1.Top + NewStaticText1.Height + 8;
Width := NewStaticText1.Width;
Height := ScaleY(30);
Caption := 'Eliminar partidas guardadas';
end;
但是我不知道如何link这段代码到卸载中删除附加文件夹的动作。
例如:
最终只需检查 CurUninstallStepChanged
event function and call DelTree
function 中复选框的值。
var
NewCheckBox1: TNewCheckBox; { a global variable }
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then { or usPostUninstall }
begin
if NewCheckBox1.Checked then
begin
Log('Deleting folder');
if DelTree(ExpandConstant('{userappdata}\My Program'), True, True, True) then
begin
Log('Deleted folder');
end
else
begin
MsgBox('Error deleting folder', mbError, MB_OK);
end;
end;
end;
end;
我使用以下代码为卸载程序创建了自定义页面:
NewCheckBox1 := TNewCheckBox.Create(UninstallProgressForm);
with NewCheckBox1 do
begin
Parent := UninstallfirstPage;
Left := NewStaticText1.Left;
Top := NewStaticText1.Top + NewStaticText1.Height + 8;
Width := NewStaticText1.Width;
Height := ScaleY(30);
Caption := 'Eliminar partidas guardadas';
end;
但是我不知道如何link这段代码到卸载中删除附加文件夹的动作。
例如:
最终只需检查 CurUninstallStepChanged
event function and call DelTree
function 中复选框的值。
var
NewCheckBox1: TNewCheckBox; { a global variable }
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then { or usPostUninstall }
begin
if NewCheckBox1.Checked then
begin
Log('Deleting folder');
if DelTree(ExpandConstant('{userappdata}\My Program'), True, True, True) then
begin
Log('Deleted folder');
end
else
begin
MsgBox('Error deleting folder', mbError, MB_OK);
end;
end;
end;
end;