Delphi – INNO installer cannot be imported into DLL

I have no luck importing Delphi DLL into Inno Setup(Unicode). DLL has a simple procedure..

procedure Foo(); stdcall;
begin

end;

exports
Foo;

DLL is included in the installer source , And add it to the file list:

[Files]
Source: "MyDLL.dll"; Flags: dontcopy

Then, I Extract this DLL during initialization:

function InitializeSetup(): Boolean;
begin
ExtractTemporaryFile('MyDLL.dll');
end;

Finally, this process is declared in the script:

function DoFoo(): Bool;
external'Foo@MyDLL. dll stdcall';

However, when I run the installer, an error appears:

Cannot Import dll: MyDLL.dll.

pre>

What am I doing wrong?

Since you did not use lazy loading in the function import, the Inno Setup loader cannot run because It cannot find your library. This is because checking whether the function export is available is performed before the InitializeSetup event is triggered, so your library has not been extracted from the archive.

In your case , Correctly add the delayload import option. However, if you add files, you can omit manual extraction and tell the installer to extract the library for you: the prefix before the library file name. This prefix is ​​documented:

During Setup, a special'files:' prefix may also be used to instruct
Setup to automatically extract one or more DLLs from the [ Files]
section before loading the first DLL.

The entire import in your case can be shortened to:

[Files ]
Source: "MyDLL.dll"; Flags: dontcopy[Code]procedure Foo; external'Foo@files:MyDLL.dll stdcall';

I No luck importing Delphi DLL into Inno Setup(Unicode). DLL has a simple process..

procedure Foo(); stdcall;
begin< br />
end;

exports
Foo;

DLL is included in the installer source and added to the file list:

[Files]
Source: "MyDLL.dll"; Flags: dontcopy

Then, I extract this DLL during initialization:

< p>

fu nction InitializeSetup(): Boolean;
begin
ExtractTemporaryFile('MyDLL.dll');
end;

Finally, this process is declared in the script:

function DoFoo(): Bool;
external'[email protected] stdcall';

But when I run the installer, it appears Error:

Cannot Import dll: MyDLL.dll.

What am I doing wrong?

Since you are not using lazy loading in the function import, the Inno Setup loader cannot run because it cannot find your library. This is because of checking Whether the function export is available is executed before the InitializeSetup event is triggered, so your library has not been extracted from the archive.

In your case, add the delayload import correctly Option. However, if you add files, you can omit the manual extraction and tell the installer to extract the library for you: the prefix before the library file name. This prefix is ​​documented:

During Setup, a special'files:' prefix may also be used to instruct
Setup to automatically extract one or more DLLs from the [Files]
section before loading the first DLL.

The entire import in your case can be shortened to:

[Files]
Source: "MyDLL.dll" ; Flags: dontcopy[Code]procedure Foo; external'Foo@files:MyDLL.dll stdcall';

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3111 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.