How to Marshal AnsiBstr SafeArrays in C# with PInvoke

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,

Does anyone know how to Marshal an AnsiBstr SafeArray that I use by
reference ?
The signature that I used until now is:

[DllImport("myDll", CharSet=CharSet.Auto)]
public static extern int ReadData([MarshalAs(UnManagedType.SafeArray)]) ref
string[] ar);

When I display this array the number of elements in the array is correct but
when I display the values I get all question marks. I think this is caused by
the character encoding since C# uses unicode.

I also used the "SafeArraySubType=VT_BSTR" but still question marks!

The DLL worked fine with VB6

Can anyone help me please?

Thanks
 
Back
Top