仅在需要卸载时才处理此卸载程序代码吗?

ElektroStudios

我在本[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);

我该怎么办?

ElektroStudios

该解决方案,感谢@ TLamaCurUninstallStepChanged提示,也感谢我以示例为例实现的其他答案

//////////////
// 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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

尝试处理卸载事件

来自分类Dev

我可以在自动缩放时使用AWS Code Deploy提取应用程序代码吗?

来自分类Dev

MediaElement仅在嵌入XAML代码时才播放吗?

来自分类Dev

仅在安装了模块时才需要

来自分类Dev

仅在需要时才使Inno Setup安装程序请求特权提升

来自分类Dev

为什么此C预处理程序代码不起作用?

来自分类Dev

删除预处理程序代码时重复的符号

来自分类Dev

此Linux设备驱动程序代码中是否需要自旋锁?

来自分类Dev

C#如何正确删除事件处理程序代码?

来自分类Dev

NuGet-仅在其他项目不依赖依赖项时才卸载并删除依赖项吗?

来自分类Dev

卸载不需要的应用程序

来自分类Dev

设置Inno Setup卸载程序的外观时,为什么需要使用uninsneveruninstall标志?

来自分类Dev

卸载不需要的应用程序

来自分类Dev

如何卸载此Google Chrome扩展程序?

来自分类Dev

MediaElement仅在嵌入XAML代码时才播放吗?

来自分类Dev

卸载程序仅在重新启动后才能使用。我可以覆盖此设置,这样就不必重新启动吗?

来自分类Dev

仅在需要时才使Inno Setup安装程序请求特权提升

来自分类Dev

解释C预处理程序代码

来自分类Dev

install4j在卸载时删除卸载程序脚本

来自分类Dev

C ++自动预处理程序代码生成

来自分类Dev

仅在需要时才挂载磁盘有意义吗?

来自分类Dev

似乎在#if假块中评估预处理程序代码

来自分类Dev

R /发光:仅在闪亮的应用程序中需要时才渲染图的元素

来自分类Dev

Inno Setup:仅在需要时创建卸载注册表项

来自分类Dev

如何从Windows驱动程序代码中区分devmgmt的“禁用”和“卸载”?

来自分类Dev

仅在安装或卸载时执行自定义操作

来自分类Dev

NSIS 在卸载程序中设置“需要空间”

来自分类Dev

为什么此 JS 代码仅在存在“console.log()”时才起作用?

来自分类Dev

Scheme中处理用户输入的程序代码设计

Related 相关文章

  1. 1

    尝试处理卸载事件

  2. 2

    我可以在自动缩放时使用AWS Code Deploy提取应用程序代码吗?

  3. 3

    MediaElement仅在嵌入XAML代码时才播放吗?

  4. 4

    仅在安装了模块时才需要

  5. 5

    仅在需要时才使Inno Setup安装程序请求特权提升

  6. 6

    为什么此C预处理程序代码不起作用?

  7. 7

    删除预处理程序代码时重复的符号

  8. 8

    此Linux设备驱动程序代码中是否需要自旋锁?

  9. 9

    C#如何正确删除事件处理程序代码?

  10. 10

    NuGet-仅在其他项目不依赖依赖项时才卸载并删除依赖项吗?

  11. 11

    卸载不需要的应用程序

  12. 12

    设置Inno Setup卸载程序的外观时,为什么需要使用uninsneveruninstall标志?

  13. 13

    卸载不需要的应用程序

  14. 14

    如何卸载此Google Chrome扩展程序?

  15. 15

    MediaElement仅在嵌入XAML代码时才播放吗?

  16. 16

    卸载程序仅在重新启动后才能使用。我可以覆盖此设置,这样就不必重新启动吗?

  17. 17

    仅在需要时才使Inno Setup安装程序请求特权提升

  18. 18

    解释C预处理程序代码

  19. 19

    install4j在卸载时删除卸载程序脚本

  20. 20

    C ++自动预处理程序代码生成

  21. 21

    仅在需要时才挂载磁盘有意义吗?

  22. 22

    似乎在#if假块中评估预处理程序代码

  23. 23

    R /发光:仅在闪亮的应用程序中需要时才渲染图的元素

  24. 24

    Inno Setup:仅在需要时创建卸载注册表项

  25. 25

    如何从Windows驱动程序代码中区分devmgmt的“禁用”和“卸载”?

  26. 26

    仅在安装或卸载时执行自定义操作

  27. 27

    NSIS 在卸载程序中设置“需要空间”

  28. 28

    为什么此 JS 代码仅在存在“console.log()”时才起作用?

  29. 29

    Scheme中处理用户输入的程序代码设计

热门标签

归档