Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FindWindow
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00172288
Message ID:
00172458
Views:
51
Hi Ed,

>All STRING declarations are ByRefs; what is passed to the API call is the same regardless of whether your DECLARE...DLL has a STRING cSomeValue or a STRING @ cSomeValue. I don't know why this occurs, and it doesn't make sense, but it does appear to be the behavior.

Yes and no. As you probably know in C strings are generally passed as a pointer to the string, that's why VFP doesn't make a distiction in the call. In C terms the first is function(const char*) and the second function(char*). Both definitions produce the same code, in C it's the compiler that verifies that you don't alter the passed string.

The definition doesn't really matter, but how you call the API function does matter. When you pass a string by reference, VFP passes a pointer to the actual string, when you pass it by value, it passes a pointer to a copy of the string. The following code sample illustrates this:
Declare Integer GetSystemTime in Win32Api String
lcBuffer = Space(255)
GetSystemTime(lcBuffer)
? ">",lcBuffer,"<"         && empty string
GetSystemTime(@lcBuffer)
? ">",lcBuffer,"<"         && SYSTEMTIME strucutre 
Christof
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform