title: Pass array by reference from Delphi 7 to C++ Dll
body: <p>Here is the C++ function exposed through the DLL:</p>
  
  <pre><code>double my_exposed_cpp_function(int* my_array){
   int i = my_array[2]; /* i should be 3 */
   my_array[2]++;
   return 0;
  }
  </code></pre>
  
  <p>Here is the declaration of my Delphi function</p>
  
  <pre><code>function dll_function(var my_array: array of integer): Real; stdcall; external myDLL name 'my_exposed_cpp_function';
  </code></pre>
  
  <p>Here is what I would like to do in the Delphi function</p>
  
  <pre><code>procedure talk_to_dll();
  var
   return_value: Real;
   my_array: array[0..2] of integer;
   final_value: integer;
  begin
   my_array[0] = 1;
   my_array[1] = 2;
   my_array[2] = 3;
   return_value := dll_function(my_array);
   final_value = my_array[2]; /* my_array[2] should now be 4 */
  end;
  </code></pre>
  
  <p>Hopefully that example makes my intentions clear. I can use this setup to work with simpler data types so I know that the communication between Delphi and the dll is fine. What do I need to change to get this working?</p>