title: PInvoke a struct pointer to get the data
body: <p>C code:</p>
  
  <pre><code>// Device description structure
  struct DeviceInfo
  {
    unsigned short deviceID;
    unsigned short productID;
    unsigned short versionNumber;
    wchar_t* deviceName;
  }; 
  
  void __cdecl GetAttachedDevices(
    int* count,
    DeviceInfo* deviceInfoList
  );
  </code></pre>
  
  <p>and PInvoke C# code to work with this C DLL:</p>
  
  <pre><code>    public struct DeviceInfo
      {
          public ushort deviceID;
          public ushort productID;
          public ushort versionNumber;
          public IntPtr deviceName;
      }; 
  
      [DllImport("Native.dll", CallingConvention=CallingConvention.Cdecl)]
      public static extern void GetAttachedDevices(ref int count, ref DeviceInfo deviceInfoList);
  </code></pre>
  
  <p>When I use this C# code:</p>
  
  <pre><code>    int count = 0;
      DeviceInfo dev = new DeviceInfo();
  
      GetAttachedDevices(ref count, ref dev);
  </code></pre>
  
  <p>I only get one device info in <em>dev</em> (when there are 2 devices in <em>count</em>).</p>
  
  <p>What should I do to get all devices data?</p>