It is pretty simple. You define the delegate type in the same way as the standard p / invoke.
Here is the simplest example that I can think of:
WITH#
using RGiesecke.DllExport;
namespace ClassLibrary1
{
public delegate int FooDelegate();
public class Class1
{
[DllExport()]
public static int Test(FooDelegate foo)
{
return foo();
}
}
}
Delphi
program Project1;
{$APPTYPE CONSOLE}
type
TFooDelegate = function: Integer; stdcall;
function Test(foo: TFooDelegate): Integer; stdcall; external 'ClassLibrary1.dll';
function Func: Integer; stdcall;
begin
Result := 666;
end;
begin
Writeln(Test(Func));
end.
Output
666
# CallingConvention.Stdcall, . .