title: How do I declare this dll method in Delphi?
body: <p>I have a function in a DLL (the c header is):</p>
  
  <pre><code>int my_c_function(
      const int cnames[10], const char *delim, size_t delim_size,
      char *buffer, size_t *buffersize);
  </code></pre>
  
  <p>I've tried </p>
  
  <pre><code>function my_c_function(cnames: Array of integer;
                         const delim : PAnsiChar;
                         delim_size : integer;
                         buffer : array of Byte;
                         BufferSize: integer): integer; cdecl;
  
  implementation
  
  function my_c_function(cnames: Array of integer;
                         const delim : PAnsiChar;
                         delim_size : integer;
                         buffer : array of Byte;
                         BufferSize: integer): integer; cdecl; external 'mydll.dll';
  </code></pre>
  
  <p>But it crashes when I try to call the function.</p>
  
  <p>But the following C# import works fine...</p>
  
  <pre><code>[DllImport("mydll.dll", CharSet = CharSet.Ansi,CallingConvention =CallingConvention.Cdecl)]
  public static extern int my_c_function(int[] cnames, string delim, int  delim_size, StringBuilder buffer, ref  int BufferSize);
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Is is the way I need to initialise the Buffer and BufferSize in Delphi?</p>