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