title: Sending an Array of strings from c# to c++ via COM
body: <p>I tried to send an array from c# to c++ via com interop. </p>
  
  <p>Here is the c# Code </p>
  
  <pre><code>public void SendArraytoCPlusPlus()
  {
      GGXForVBA.GeoAtlas GA = new GGXForVBA.GeoAtlas();
      string[] arr = new string[3];
      arr[0] = "One";
      arr[1] = "Two";
      arr[2] = "Five";
      GA.GetArrayVar(arr);
  }
  </code></pre>
  
  <p>Here is the c++ code </p>
  
  <pre><code>void GeoAtlas::GetArrayVar(VARIANT&amp; arr)
  { 
      AFX_MANAGE_STATE(AfxGetStaticModuleState());
      SAFEARRAY* pSafeArray = arr.parray;
      long lStartBound = 0;
      long lEndBound = 0;
      SafeArrayGetLBound(pSafeArray,1,&amp;lStartBound);
      SafeArrayGetUBound(pSafeArray,1,&amp;lEndBound);
      LPCSTR * arrayAccess = NULL;
  
      SafeArrayAccessData( pSafeArray , (void**)&amp;arrayAccess);
      for(int iIndex = lStartBound; iIndex &lt;= lEndBound; iIndex ++)
      {   
          LPCTSTR myString = (LPCTSTR)arrayAccess[iIndex];
          AfxMessageBox(myString);        
      }  
  }
  </code></pre>
  
  <p>This is the idl</p>
  
  <pre><code>[id(23)] void GetArrayVar(VARIANT arr);
  </code></pre>
  
  <p>The problem is, The message box only shows the FIRST letters of the strings, i.e ''O'. 'T', 'F' . I want to read the whole string. Any suggestions ?</p>