How to Marshal AnsiBstr SafeArrays in C# with PInvoke

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top