3

I want to import two dlls in my .iss when uninstalled the app. I cannot find a way to do this.

procedure Installed();
external 'Installed@files:StatisticInstallInfo.dll,adcore.dll cdecl  setuponly ';

procedure Uninstalled();
external 'Uninstalled@{app}\StatisticInstallInfo.dll cdecl  uninstallonly';

I want import adcore.dll in procedure Uninstalled too. And it's failed as below shows;

[Files]
Source: {#MyDefaultPackDir}\adcore.dll; DestDir: "{app}"
Source: {#MyDefaultPackDir}\StatisticInstallInfo.dll; DestDir: "{app}"
[Code]
procedure Uninstalled();
external 'Uninstalled@files:StatisticInstallInfo.dll,adcore.dll cdecl  uninstallonly';

It does not work.

Installed() and Uninstalled() are in the StatisticInstallInfo.dll, which depends on adcore.dll.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
user861491
  • 149
  • 1
  • 11

1 Answers1

6

When the installer is running, Inno has access to the contents of the setup, and so can extract any files needed using the files:file1.dll,file2.dll syntax.

At uninstall time, Inno no longer as access to the contents of the setup so it needs to rely on anything you extracted at install time using a normal [Files] entry. Because of this, it no longer cares about the dependencies and leaves that up to you.

[Files]
Source: "StatisticInstallInfo.dll"; DestDir: "{app}"
Source: "adcore.dll"; DestDir: "{app}"

[Code]
procedure Installed();
external 'Installed@files:StatisticInstallInfo.dll,adcore.dll cdecl setuponly';

procedure Uninstalled();
external 'Uninstalled@{app}\StatisticInstallInfo.dll cdecl uninstallonly';

Depending on when you call that function (if after the install itself) you can scrap the files:... syntax and just use {app}\StatisticInstallInfo.dll in both cases.

Deanna
  • 23,876
  • 7
  • 71
  • 156
  • what you mean is that I use {app}\StatisticInstallInfo.dll. and it auto call the function in adcore.dll? – user861491 Sep 25 '12 at 12:34
  • 1
    Yes, that is handled by your `StatisticInstallInfo.dll` at both install and uninstall time. The `files:a.dll,b.dll` just causes both to be extracted, nothing more. Installing them both to `{app}` does the same thing, it just makes sure they are both extracted to use. – Deanna Sep 25 '12 at 12:36
  • You may need the [`loadwithalteredsearchpath` flag](https://jrsoftware.org/ishelp/index.php?topic=scriptdll&anchor=loadwithalteredsearchpath). See [Loading DLL with dependencies in Inno Setup fails in uninstaller with “Cannot import DLL”, but works in the installer](https://stackoverflow.com/q/65018560/850848) – Martin Prikryl Nov 30 '20 at 12:41