inno-setup - 在inno setup中卸载一个应用程序时我可以控制要卸载的内容吗?

标签 inno-setup

关于 inno-setup 的一个简单问题:我可以自定义卸载程序要删除哪些文件吗?据我所知,卸载程序总是卸载安装程序创建的所有文件。如果答案是肯定的,我该怎么办?

我的情况是:安装应用程序后,目录“{pf}\myapp\”包含一些dll、两个可执行文件,并为每个可执行文件创建了两个桌面图标和卸载程序。我期望用户可以卸载每个可执行文件,而不是所有文件;如果它是唯一剩下的可执行文件,卸载程序将删除所有文件。

提前致谢。

最佳答案

如果您想要单独的卸载程序,则必须编写单独的安装程序。一般规则是您必须为每个应用程序编写一个单独的安装程序。

也就是说,您可以拥有任意数量的共享文件,这些文件可以是在不同应用程序之间共享的 dll、可执行文件等。

Windows 有明确定义的过程来跟踪共享文件,并带有引用计数。引用计数由安装程序增加并由卸载程序减少。仅当卸载过程中引用计数达到 0 时,文件才会从系统中删除。

您可以使用sharedfile标志来指示安装程序共享文件。 MyLib.dll 文件在以下示例中共享:

[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "MyLib.dll"; DestDir: "{sys}"; Flags: sharedfile
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme

来自文档(强调我的):

sharedfile

Specifies that the file is shared among multiple applications, and should only be removed at uninstall time if no other applications are using it. Most files installed to the Windows System directory should use this flag, including .OCX, .BPL, and .DPL files.

Windows' standard shared file reference-counting mechanism (located in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs) is used to keep track of how many applications depend on the file. Each time the file is installed, the reference count for the file is incremented. (This happens regardless of whether the installer actually replaces the file on disk.) When an application using the file is uninstalled, the reference count is decremented. If the count reaches zero, the file is deleted (with the user's confirmation, unless the uninsnosharedfileprompt flag is also specified).

关于inno-setup - 在inno setup中卸载一个应用程序时我可以控制要卸载的内容吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14971858/

相关文章:

inno-setup - 如何在 [Run] 部分只允许一个复选框?

inno-setup - Inno Setup 在安装过程中禁用取消按钮

inno-setup - inno 设置末尾的奇数 "List Index out of Bounds (20)"

inno-setup - 在一个安装程序中执行多个安装程序/exe?

formatting - 在 Inno Setup isl 文件中格式化文本的选项

checkbox - 向标准 Inno Setup 页面添加额外的控件?

inno-setup - 如何使用运行部分来执行文件并从函数中读取参数

inno-setup - 在 Inno Setup 中创建使用命令行参数执行程序的快捷方式

inno-setup - Inno Setup 如何在用户选择目标目录后设置 AppId?

java - Inno Setup - 如何自动允许 Java 通过防火墙