我在本[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;
问题是即使InnoSetup卸载程序询问用户是否真的要卸载软件时,即使用户选择“是”或“否”DeinitializeUninstall
,“DeleteFile
和”过程中的指令仍会DelTree
运行,我的意思是用户选择此图像:
当然,我知道该过程的含义以及为什么即使选择“否”也可以运行我的指令,因为无论我选择什么,卸载程序都会被初始化,但是我找不到有效地执行此操作的正确方法。
所以,我需要PROCESSS下面只有当用户真的需要一个卸载选择这两个指令是,而且这些指令应该在卸载过程结束时运行(这是DeinitializeUninstall
程序我supose):
DeleteFile(ExpandConstant('{app}\uninstall.dll'));
DelTree(ExpandConstant('{app}\'), true, DeleteFiles, DeleteSubdirs);
我该怎么办?
该解决方案,感谢@ TLama的CurUninstallStepChanged
提示,也感谢我以示例为例实现的其他答案:
//////////////
// 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;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句