我在[Code]
部分中有此代码,此代码仅在我运行卸载程序时运行:
//////////////
// Uninstaller
//////////////
const
DeleteFiles = true;
DeleteSubdirs = false;
// Initialize the Inno Setup Uninstaller skin style.
function InitializeUninstall: Boolean;
begin
Result := True;
LoadVCLStyle_UnInstall(ExpandConstant('{app}\uninstall.vsf'));
end;
// Deinitialize the Inno Setup Uninstaller skin style.
procedure DeinitializeUninstall();
begin
UnLoadVCLStyles_UnInstall;
UnloadDll(ExpandConstant('{app}\uninstall.dll'));
DeleteFile(ExpandConstant('{app}\uninstall.dll'));
DelTree(ExpandConstant('{app}\'), true, DeleteFiles, DeleteSubdirs);
end;
问题是即使用户选择是或否{},DeinitializeUninstall
和DeleteFile
DelTree
程序内的说明也会运行strong>当InnoSetup卸载程序询问用户是否真的要卸载软件时,我的意思是用户选择此图像:
当然,我理解该程序的含义以及为什么我的指令运行甚至选择否,因为卸载程序无论我选择了什么都已取消初始化,但我无法找到正确的方法来有效地执行此操作。
因此,只有当用户真正要求卸载选择是时,才需要处理以下两条说明,但这些说明也应该在卸载过程结束时运行(那就是{{ 1}}程序我嘲笑):
DeinitializeUninstall
我怎么做?
答案 0 :(得分:1)
解决方案,感谢@ {strong> TLama 提供了CurUninstallStepChanged
提示,感谢this other answer我已经举例说明了这一点:
//////////////
// Uninstaller
//////////////
Const
DeleteFiles = True; // Determines whether to delete all the files of the {app} dir.
DeleteSubdirs = False; // Determines whether to delete all the sub-folders of the {app} dir.
Var
UninstallIsDemanded: Boolean; // Determines whether the user accepted or denied the uninstallation prompt.
UninstallSuccess : Boolean; // Determines whether the uninstallation succeeded.
// Occurs when the uninstaller current page changes.
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then begin
UninstallIsDemanded:= True;
end;
if CurUninstallStep = usDone then begin
UninstallSuccess:= True;
end;
end;
// Deletes the VCL skin dll file.
procedure DeleteSkin();
begin
DeleteFile(ExpandConstant('{app}\uninstall.dll'));
end;
// Deletes the 'app}' file/folder contents.
procedure DeleteApplication(DeleteFiles: Boolean; DeleteSubdirs: Boolean);
begin
DelTree(ExpandConstant('{app}\'), true, DeleteFiles, DeleteSubdirs);
end;
// Initialize the Inno Setup Uninstaller skin style.
function InitializeUninstall: Boolean;
begin
Result := True;
LoadVCLStyle_UnInstall(ExpandConstant('{app}\uninstall.vsf'));
end;
// Deinitialize the Inno Setup Uninstaller skin style.
procedure DeinitializeUninstall();
begin
UnLoadVCLStyles_UnInstall;
UnloadDll(ExpandConstant('{app}\uninstall.dll'));
if UninstallSuccess = True then begin
DeleteSkin();
DeleteApplication(DeleteFiles, DeleteSubdirs);
end;
end;