c# - Unmanaged Exports and delegates -
i using robert giesecke unmanaged exports create .net wrapper dll utilize .net dll in delphi 7. works fine far, have function needs have callback/delegate.
how can done?
can give function pointer .net dll , phone call there , when yes how done?
it's pretty simple. define delegate type standard p/invoke.
here's simplest illustration can think of:
c#
using rgiesecke.dllexport; namespace classlibrary1 { public delegate int foodelegate(); public class class1 { [dllexport()] public static int test(foodelegate foo) { homecoming 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
666the default calling convention on c# side callingconvention.stdcall i've gone along that. that's obvious thing do.
c# delphi dll delphi-7
No comments:
Post a Comment