Jeremy, Christian is correct (though you'd eventually put it in a for
loop to get all the strings, not just the first one).
By the way, a C++ longs is an VB Integer (or Int32 or UInt32) in .NET
so you have another slight error.
Tom
> >>r = GetAllFormationNames(1, 2, numdata, ids, ip)
> >>
[quoted text clipped - 5 lines]
> to string data, it points to the array of char pointers.
> Try Marshal.PtrToStringAuto(Marshal.ReadIntPtr(ip,0)).
Aha - now we are getting there..
I can now get a whole array of strings back like this:
>r = GetAllFormationNames(1, 2, numdatap, idsp, ipp)
>
[quoted text clipped - 14 lines]
> Next
> End If
however at (seemingly) random points in the formationnames array I get
short (1 or 2 chars) strings of characters with ascii values over 128
- I originally tried incrementing offset by the value of the last
string found instead of by 1, but then I found that a lot of the
elements of formationnames were empty..
..I can write a check to ensure that the strings returned are
alphanumeric, but that's a rather ugly solution!
anyway - thanks for the help in getting to this point!
Jeremy
>>>r = GetAllFormationNames(1, 2, numdata, ids, ip)
>>>
[quoted text clipped - 5 lines]
>to string data, it points to the array of char pointers.
>Try Marshal.PtrToStringAuto(Marshal.ReadIntPtr(ip,0)).
TDC - 25 Aug 2006 16:45 GMT
I think offset is a byte-offset as opposed to an IntPtr-width offset.
In other words, since an IntPtr is 4 bytes, increment the offset by 4
each time.
Tom
> Aha - now we are getting there..
>
[quoted text clipped - 41 lines]
> >to string data, it points to the array of char pointers.
> >Try Marshal.PtrToStringAuto(Marshal.ReadIntPtr(ip,0)).
TDC - 25 Aug 2006 16:50 GMT
Just noticed your while...I don't know why that is there. It should
look more like this:
For ndx as Integer = 0 to numOfNames -1
formationnames(ndx) =
Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(ptr, offset))
offset += 4
Next ndx
Tom
TDC - 28 Aug 2006 13:12 GMT
Jeremy,
Be sure to let us know how you made out. That way everyone can learn
what works and what doesn't.
Tom
> Just noticed your while...I don't know why that is there. It should
> look more like this:
[quoted text clipped - 8 lines]
>
> Tom