View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default CopyMemory - Array of UDTs referenced as a pointer to a string

Strings are null terminated not arrays. Also known as ASCII Z. The API is
quite probably done in C. C doesn't tell you anything about the pointerjust
that something you are looking for starts at this point in memory. It is up
to the C Programmer to figure out how much memory you want to read. From a
Visual Basic stand point you are kind of lost. Unless you can find out how
many elements are in the array you will not be able to retrieve the values of
the array. Best of luck to you...

"Mark Stacey" wrote:

Data is sent to me by an API which returns a pointer to a "string" which
is actually a data structure. I use CopyMemory(Alias RtlMoveMemory) to
get access to this data in my own UDT's.
My problem arises in that sometimes the data will be returned as an
array of structs. The API doesn't provide for letting me know the size
of the array, and getting the length of the string just gives me the
length of one element.
The API is not written in VB, so I think that means it's a
null-terminated array, if so how do I copy each of the elements in my
own array of equivalent structure?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!