Hi,
First of all, char * is a String (LPStr actually).
But the chips parameter poses a difficulty indeed, since AFAIK [][]
means an continuous sequence of strings, not even an array of LPStr's
8=[.
And I don't see a way to pass this except allocating the memory and
positioning strings manually. So that's the declarations:
~
Const S00X_ANTICOLL_ARRAY As Integer = 64
Declare Ansi Function S00X_ReadC220 Lib "MedioSTX.dll" ( _
ByVal useconfig As Boolean, _
ByVal changeconfig As Boolean, _
ByVal anticollision As Boolean, _
ByVal listeningtime As Double, _
<MarshalAs(UnmanagedType.LPStr)> ByVal nbchips As String, _
ByVal chips As IntPtr, _
<MarshalAs(UnmanagedType.LPStr)> ByVal cmdstatus As String _
) As Integer
~
And the usage:
~
Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
MyBase.OnClick(e)
Dim ChipsA() As String = {"JC Denton", "Alex Jacobson", "Jaime
Reyes", "Joseph Manderley"}
' I presume you have a string array called ChipsA
' strings' length must not exceed S00X_ANTICOLL_ARRAY,
' or you'll get garbage!
Dim base As IntPtr, cur As Integer
base = Marshal.AllocHGlobal(S00X_ANTICOLL_ARRAY * ChipsA.Length)
cur = base.ToInt32
For Each str As String In ChipsA
'Copy the string...
Marshal.Copy(System.Text.Encoding.Default.GetBytes (str), 0,
New IntPtr(cur), str.Length)
'... and append the terminating NULL.
Marshal.WriteByte(New IntPtr(cur), str.Length, CByte(0))
cur += S00X_ANTICOLL_ARRAY
Next
'Use function with base as chips:
'S00X_ReadC220(blah blah blah...)
Marshal.FreeHGlobal(base)
End Sub
~
Whew... This was a bit harder that I initially expected.. 8=]
Unfortunately, I don't have a library to test this on, but it should
work.
Hope this helps,
Roman