>>I am working with a DLL that expects to be passed a structure or reference to a structure for many of the functions. I've tried passing a string or array instead without luck. How can you pass a structure from VFP?
>
>I've been playing with this some more and just can't get it to work. For example, one function expects to be passed a reference to a structure with two items in the structure: program name, of type string, and program version of type integer. In VB it would look something like...
>
>Type VERSIONS_REC
> Prog_name AS String * 20
> Prog_ver AS Integer
>End Type
>
>So, the function would return the program name and program version to that structure. I've tried passing just a string value, but the DLL only returns the first item in the structure to the string. I've also tried passing an array, but get data-type mismatch errors for these. I don't have any other ideas. Anyone?
Michael,
You can simulate the sturcture by using a string. In the example above, the string would be 24 characters in length (20 for the string part, 4 for the integer). Your problem may be in passing the integer portion. You need to convert the value into 4 characters in least significant to most significant byte order. For example, 9204 (23F4 Hex) would be represented by CHR(244) + CHR(35) + CHR(0) + CHR(0). Adding this string onto the other portion will give you the structure you require.
Paul Vlad Tatavu has a class in the download section (under Win32 & other APIs) that has functions to accomplish this.
hth,
George
George
Ubi caritas et amor, deus ibi est