Load external DLL for uninstall process in Inno Setup

吃可爱长大的小学妹 提交于 2019-11-29 08:43:15

I assume you are getting the error, when starting the installer, not the uninstaller.

When the installer is starting, the {app} is obviously unknown yet.

But as you need the import for the uninstaller only, which knows the {app}, you can add the uninstallonly option:

procedure uLoadVCLStyle(VClStyleFile: String); 
  external 'LoadVCLStyleW@{app}\VclStylesInno.dll stdcall uninstallonly';

Though it does not really help, as the uninstaller will want to remove the DLL, failing, as it has the DLL locked itself.

The solution is simple, just follow the official instructions for uninstalling the VCL Styles for Inno Setup.

You basically need to install the DLL somewhere else than in the {app} and leave the DLL behind when uninstalling. That's actually an ugly solution, which imho does not justify a styled uninstaller. But it's your choice.


As you suggested, you may copy the DLL to Windows temporary folder, load it from there and hope for Windows to eventually delete the DLL during temporary directory cleanup.

This should do (note the delayload option):

[Files]
Source: VclStylesinno.dll; DestDir: {app}

[Code]

procedure LoadVCLStyle_UnInstall(VClStyleFile: String); 
  external 'LoadVCLStyleW@{%TEMP}\VclStylesInno.dll stdcall uninstallonly delayload';

function InitializeUninstall: Boolean;
begin
  if FileCopy(ExpandConstant('{app}\VclStylesinno.dll'),
              ExpandConstant('{%TEMP}\VclStylesinno.dll'), False) then
  begin
    LoadVCLStyle_UnInstall(...);
  end;
end;

For another solution (better but more complicate to implement), see How keep uninstall files inside uninstaller?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!