I have a big problem. I have a delphi5 application that calls C # dll. I want to call a function from my C # dll that needs a pointer to the delphi procedure as an input parameter. In this C # function, the delphi procedure is called afterwards.
I tried declaring a pointer to the C # side using IntPtr:
ourFunction(IntPtr fct){
...
helpFct = (OurType)Marshal.GetDelegateForFunctionPointer(fct, typeof(OurType));
...
}
If I call a function from C #, everything works fine. But if I want to call it from Delphi (with the delphi procedure as an input parameter), it crashes without giving me any error information.
here is my delphi code:
hBuffer : THandle;
buffer : PInteger;
...
hBuffer:=GlobalAlloc(GMEM_fixed,SizeOf(Integer));
buffer:=GlobalLock(hBuffer);
buffer := Addr(AddDelphi);
intfRef.ourFunction(buffer^);
Does anyone have any experience with such problems or any ideas how this might work?
thanks Stefan
source
share