I’m using a C dll in a Delphi XE2 program without problem. One of the DLL function takes a function as argument.
Here is the prototype of the function:
var
LMX_MySetOption: function(LmxHandle: LMX_HANDLE;
eOption: _LMX_SETTINGS;
callback: TCallBackProcedure): LMX_STATUS cdecl
{$IFDEF WIN32} stdcall {$ENDIF};
The original prototype in C of the function was:
LMX_STATUS LMX_SetOption(LMX_HANDLE LmxHandle, LMX_SETTINGS eOption,
const void *pSetting);
TCallBackProcedure is defined as follow:
type
TCallBackProcedure = procedure(bla : Pointer) stdcall;
I’m calling the function this way:
LMX_MySetOption(LmxHandle, LMX_OPT_HEARTBEAT_EXIT_FUNCTION, UserExitRoutine);
The UserExitRoutine is definede as follow:
procedure UserExitRoutine(bla : Pointer) stdcall;
begin
...
end;
It’s not working (access violation)
I can’t modify the C dll.
Many thanks for any idea!
If is a C procedure don’t use stdcall use cdecl .
And you can simply declare this
It should work…if it doesn’t maybe you don’t know the exact nr of parameters that the function has…