title: C# dll import function correctly
body: <p>I am trying to import a function from a c dll into C#.  The c function looks like this</p>
  
  <pre><code>unsigned short write_buffer( unsigned short device_number, unsigned short word_count, unsigned long buffer_link, unsigned short* buffer)
  </code></pre>
  
  <p>my attempt at a C# import looks like this</p>
  
  <pre><code>[DllImport("sslib32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
  private static extern ushort write_buffer(ushort deviceNumber, ushort wordCount, UInt32 bufferLink, IntPtr buffer)
  </code></pre>
  
  <p>In C# i have a  Dictionary of messages that i would like to pass to this function.  The Dictionary looks like this:</p>
  
  <pre><code>Dictionary&lt;string, List&lt;ushort&gt;&gt; msgs
  </code></pre>
  
  <p>I am a bit confused how to make a make a proper call to pass msgs as the buffer.  deviceNumber is 2, wordCount is 32, and buffLink is 0.  So i know the call should look something like this</p>
  
  <pre><code>write_buffer(2,32,0, msgs[key]);
  </code></pre>
  
  <p>Obviously i am getting an invalid argument for the IntPtr.  What is the proper way to make this call?</p>