Declare a function pointer in Delphi by declaring a function type. For example, the type of function for your callback can be defined as follows:
type TGetProperty = function(object_type, object_instnace, property_identifier, device_identifier: UInt; value: PSingle): Boolean; cdecl;
Note that the cdecl calling cdecl is because your C ++ code does not specify a calling convention, and cdecl is the usual standard default convention for C ++ compilers.
Then you can use this type to define the function of the DLL:
function RegisterCallbackGetProperty(GetProperty: TGetProperty): Boolean; cdecl; external 'dllname';
Replace 'dllname' with the name of your DLL.
To call a DLL function, you must first have a Delphi function with a signature that matches the type of the callback. For instance:
function Callback(object_type, object_instnace, property_identifier, device_identifier: UInt; value: PSingle): Boolean cdecl; begin Result := False; end;
Then you can call the DLL function and pass the callback just like any other variable:
RegisterCallbackGetProperty(Callback);
source share