Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
CopyMemory - Array of UDTs referenced as a pointer to a string
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! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
CopyMemory - Array of UDTs referenced as a pointer to a string
Sorry I just re-read your question. In C there is no such thing as a string.
There is only a null terminated array of characters. When you de-reference the pointer to the arry you get the string. In C the de-reference retrieves all characters up until Null or ASCII Z is returned. "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! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
CopyMemory - Array of UDTs referenced as a pointer to a string
So what if I passed the string (by reference) to a C dll, (not as
arbitrary as it sounds, I already use a C dll [well, C++, it's compiled in MSVC, it's all ANSI-C tho] called from the VB app for some calculations), which can then determine the length of the data, return that value to VB, which then calculates the number of array elements, and copies out each element into the UDT. CopyMem into a string, then use MidB (MidB not Mid because this is not all character data) to move into a temp string, and CopyMem that string into the UDT, for each element. That assumes that the array is stored contiguously, which as I understand it is correct. How do I determine the length of an array in C? I can't use any C++ code, all my C-code has to be able to be recompiled in other compilers. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
CopyMemory - Array of UDTs referenced as a pointer to a string
Can I just do this:
double __stdcall lenArr( const char* strArr ) { return (int)strlen( strArr ); } ? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
last number array from string | Excel Worksheet Functions | |||
Passing a String in Array to Range as String | Excel Programming | |||
Copy Array pointer rather than entire array | Excel Programming | |||
Vlookup, table array is referenced in another cell | Excel Programming | |||
Convert a string to an array | Excel Programming |