[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Mashalling for safe array of BSTR

Cheng Wu

6/1/2007 5:13:00 AM

Hi Gurus,

I have a C application that pass strings to VB.net 2005 application. These
strings are not C strings and can have null embeded within the string.
However, the C application knows the length of each string. Now, if I pass
only a single string, the VB will receive the BSTR in full when the
declaration is
Declare Function func1 Lib "ST2.dll" Alias (<MarshalAs(UnmanagedType.BStr)>
ByRef s1 As String) As Integer

However, when I try to pass in the strings in a safe array, with the
following delaraction

Declare Function func1 Lib "ST2.dll" Alias (<MarshalAs(UnmanagedType.BStr,
SafeArraySubType:=VarEnum.VT_BSTR)> ByRef s1()As String) As Integer

The stings are actually cut off at places where there is a NULL. How else
can I pass an array of string from my C application to a VB dot net 2005
application, keeping in mind that the string can have embedded null.

Please advise and thank you in advance.

With regards,
Cheng Wu