1

See also:

Deleting and unregistering DLL files during install using Inno Setup

Inno Setup: How to automatically uninstall previous installed version?

In the [Files] section of my Inno Setup script, I have the line:

Source: {#InstallSource}\OldDll.dll; DestDir: {sys}; Flags: sharedfile regserver

This DLL is no longer used by the updated version of the application. What I'd like to do on installation of the new version is to reduce the shared file lock count for this DLL, and, if it's zero, unregister and delete it.

The simplest way to do this is to tell the users to uninstall the previous version of the application before updating, but this will mean that various configuration settings will also be deleted, and the users will have to re-enter them manually. Is it possible to automate the DLL unregistration/deletion process?

Tevildo
  • 340
  • 2
  • 11

1 Answers1

2

While you can do this to unregister and uninstall the DLL:

... it's will actually break reference counting, as it won't prevent your uninstaller from decreasing a reference counter once more. This is because the uninstaller remembers actions of all past versions of the installer and will process them all.

Example: If your DLL is shared by your application and one another - 2 references. You run your update, which decreases the counter to 1. Then you uninstall your application, which decreases the counter to 0 and deletes the DLL => The other application breaks.


So in the end the only really correct solution is to run uninstaller, at the beginning of your installer.

See Inno Setup: How to automatically uninstall previous installed version?

You can do this only conditionally, when the shared file still exists.


Though, it turned out that you do not really need to uninstall the shared DLL by the new version of the installer. You only feared that when the new installer does not install the shared DLL anymore, its uninstaller won't uninstall it correctly either. But it will, exactly for the reasons mentioned in the first section.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992