Originally asked here, but was asked to submit it as a separate question.
I have the following dll coded in C below that I\'m using in an Inno Setup Installer to ext
Have a look at the example script included with InnoTools Callback.
It's pretty straightforward, you just declare a procedure like this (again, assuming that you're using ANSI Inno -- some of the types would have to be changed for the Unicode version):
[Code]
type
TMyCallback = procedure(Filename: PChar);
function WrapMyCallback(Callback: TMyCallback; ParamCount: Integer): LongWord;
external 'WrapCallback@files:innocallback.dll stdcall';
procedure DoSomethingInTheDll(Blah: Integer; Foo: String; ...; Callback: LongWord);
external 'DoSomethingInTheDll@files:mydll.dll stdcall';
procedure MyCallback(Filename: PChar);
begin
// do whatever, eg. update the filename label
end;
// wherever you're about to call your DLL
var Callback : LongWord;
// ...
Callback := WrapMyCallback(@MyCallback, 1); // 1 parameter
// pass the callback to your DLL either via a dedicated function
// or as a parameter of your existing function
DoSomethingInTheDll(blah, foo, ..., Callback);
On the DLL side:
typedef void (__stdcall *MyCallback)(const char *filename);
You can then declare variables of type MyCallback
in function parameters and then call them as if they were native C functions, and it will run the code inside the Inno script.
void __stdcall __declspec(dllexport)
DoSomethingInTheDll(int blah, const char *foo, ..., MyCallback callback)
{
// ...
callback(foo);
}