I want to call a function from a .NET DLL (coded in C#) from an Inno Setup script.
I have:
[Files]
Source: c:\temp\1\MyDLL.dll; Flags: dontcopy
[Code]
function MyFunction(): string;
external 'MyFunction@files:MyDLL.dll stdcall setuponly';
but I still get the following error:
Runtime Error (at -1:0):
Cannot Import dll:C:\DOCUME~1\foo\LOCALS~1\Temp\is-LRL3E.tmp\MyDLL.dll.
What am I doing wrong?
Inno Setup is a free software script-driven installation system created in Delphi by Jordan Russell. The first version was released in 1997.
Inno Setup's [Code] section uses Pascal (or Pascal Script to be more exact, thanks to TLama), likely because Inno Setup itself is written in Pascal Delphi.
Go to Menu, Project, then Compile to compile and create the setup file. This will create a complete installer. Run the Setup and your application will be installed correctly. Innosetup offers an awesome alternative to create great looking Installers for free.
I read a little bit more about it - now I can see the difference between importing a C-style function and creating an OLE object.
Something like this would work for me:
[Code]
procedure MyFunction();
var
oleObject: Variant;
begin
oleObject := CreateOleObject('MyDLL.MyDLL');
MsgBox(oleObject.MyFunction, mbInformation, mb_Ok);
end;
but it requires registering the DLL file.
I guess I will have to create a command-line application to call the functions from the DLL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With