title: How to correctly declare unmanaged DLL function?
body: <p>I'm trying to call an unmanaged DLL's function in my C# app. The function declaration is <a href="http://www.spincore.com/support/spinapi/reference/production/2013-09-25/spinapi_8h.html#a108ea6212e65a83ec193260c5c7ddff9" rel="nofollow noreferrer">this</a>. The function writes to file the data from an acquisition board (i.e., from arrays <em>real_data</em> and <em>imag_data</em>).</p>
  
  <p>I'm using the following declaration, but the file contains incorrect data and I think that the declaration is wrong:</p>
  
  <pre><code>[DllImport(@"C:\SpinCore\SpinAPI\lib32\spinapi.dll", CallingConvention = CallingConvention.Cdecl)]
  public static extern int pb_write_ascii_verbose(string fname, int num_points, float SW, float SF, ref int[] real_data, ref int[] imag_data);
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>pb_write_ascii_verbose(@"C:\Users\Public\direct_data_0.txt", numberOfPoints, (float)actualSW, (float)sequence.Frequency, ref idata, ref idata_imag);
  </code></pre>
  
  <p><strong>Is this correctly declared? If so, what is the proper declaration?</strong></p>