title: How to pass an object method as a callback method to a c++ dll in Delphi
body: <p>I could pass the following to the old version of the dll</p>
  <pre><code>type
  
  PCallbackList = ^TCallbackList;
  TCallbackList = record
    arg: Pointer;
    CallBack1: procedure(arg: Pointer; p1: Pointer; error: PAnsiChar); cdecl;
    CallBack2: procedure(arg: Pointer; error: PAnsiChar); cdecl;
  end;
  </code></pre>
  <p>and when the callback is fired I cast arg to the object instance that I assigned to it before I passed the callback list.</p>
  <p>now the dll has changed and the new signature is:</p>
  <pre><code>type
  
  PCallbackList = ^TCallbackList;
  TCallbackList = record
    CallBack1: procedure(p1: Pointer; error: PAnsiChar); cdecl;
    CallBack2: procedure(error: PAnsiChar); cdecl;
  end;
  </code></pre>
  <p>so the arg pointer now is removed and I have no way to pass the reference of the object instance to the dll with the list, so I have no way to know which instance the callback belongs to.</p>
  <p>so how to pass an object method as a callback method?</p>