这很简单.您可以像使用标准p/invoke一样定义委托类型.
这是我能想到的最简单的例子:
C#
using RGiesecke.DllExport;
namespace ClassLibrary1
{
public delegate int FooDelegate();
public class Class1
{
[DllExport()]
public static int Test(FooDelegate foo)
{
return foo();
}
}
}
Run Code Online (Sandbox Code Playgroud)
德尔福
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.
Run Code Online (Sandbox Code Playgroud)
产量
666
C#端的默认调用约定是CallingConvention.Stdcall这样的,我已经同意了.这是显而易见的事情.
| 归档时间: |
|
| 查看次数: |
1130 次 |
| 最近记录: |