Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing Structures to DLLs?
Message
 
To
26/12/1997 10:21:29
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00066580
Message ID:
00068394
Views:
34
>>Well, in this case, it is actuall looking for a pointer to a structure. Then, once the function call is finished, the structure will have the proper info in it. I tried passing a reference to a string, but only the first item in the structure is saved to the string, in this case, prog_name. Here is the VFP define for that function...
>>
>>DECLARE INTEGER Czar_disp_ver IN Czar32 ;
>> STRING cProg
>>
>>
>>And here is a C++ struct that was given in an example program...
>>
>>/*
>>VERSION AND MODIFICATION STRUCTURE
>>*/
>>#define VER_DEF
>>typedef struct {
>> char czar_prog_nm[20];
>> char czar_ver_number[3];
>> char czar_mod_number[5];
>> char bczar_prog_nm[20];
>> char bczar_ver_number[3];
>> char bczar_mod_number[5];
>> char fxlib_prog_nm[20];
>> char fxlib_ver_number[3];
>> char fxlib_mod_number[5];
>> char datatype[15];
>> char compiler[6];
>>} VERSIONS;
>>
>>Thanks for the help!
>
>In the previous piece of code:
>
>#define VER_DEF
>
>defines VER_DEF to nothing. Ie: The C precompiler will replace the string "VER_DEF" with nothing. The lines following the #define declare the VERSIONS structure. If you want to use this structure as param from VFP, you must pass a string with length equal with the sum of the lengths of all elements in the structure.
>
>Being an output param, you must use the SUBSTR function to extract each element of the structure.
>
>As a general rule: all string params must be declared as passed by reference and passed by reference. Another reason to declare it and pass it by reference is the fact that the param is an output param (ie returns a value). If it returns only the first element of the structure, it may be an error somewhere else, but not in the fact that you pass it by reference.
>
>How did you see that it returns only the first element? The elements of the structure may be separated by chr(0), which is a usual string terminator. In VFP, chr(0) is not a string terminator. Still, VFP is not consistent from this point of view. Some commands and functions interpret chr(0) as string terminator (for ex: WAIT WINDOW). To do a test:
>
>a = "A" + chr(0) + "B"
>WAIT WINDOW a && This will display only the "A"
>? a && This will print the "A" and the "B" separated by a
> && square char.
>
>Use the SUBSTR function to extract each structure element. SUBSTR doesn't take chr(0) for a string terminator.
>
>Vlad

Aha! I was just putting up a wait window to verify the results. Once I tried using substr everything worked fine! Chr(0)...learn something new every day. Thanks! :)

Michael G. Emmons
memmons@nc.rr.com
Previous
Reply
Map
View

Click here to load this message in the networking platform