How to conditionally import a function from a DLL into an Inno Setup script?

I have a helper DLL and a function that I call at the end of my script installation. I just want to run it depending on the version of the operating system.

I include the following lines in the code section:

function CompleteInstall(szInstallPath: String) :  Integer;
external 'CompleteInstall@files:InstallHelper.dll cdecl setuponly';

I wrote a function to prevent the extraction of the DLL by adding in the [Files] instruction for the parameter "Validation: IsXPorHigher" in the "Source") in the [Files] section.

It seems that when I run the installer, it tries to eliminate the external function due to the external operator, causing a runtime error (Can not import ...), because my DLL relies on a function that is not available on older OSs.

Is it possible to conditionally declare a function in a script, or does this require a separate installer for older versions of the OS? I try to support only one script for all scripts.

+3
source share
1 answer

Have you tried using the parameter delayload? See the “Using DLLs” section of the Inno installation documentation in the Pascal Scripting section.

function CompleteInstall(szInstallPath: String) : Integer;
external 'CompleteInstall@files:InstallHelper.dll cdecl setuponly delayload';
+4
source

Source: https://habr.com/ru/post/1716634/


All Articles