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:
00172479
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 
Yes, and that's as expected as well - even if you pass a non-pointer item by value as a parameter in the declaration, if you pass the actual parameter by reference, you get back the value; if you pass by value, it's unaltered. That behavior is exactly as expected.

The big difference is in the declaration, passing INTEGER dwValue passes the value itself, while INTEGER @ lpdwValue passes a pointer to the value. STRING lpstr and STRING @ lpstr pass a pointer to the string at all times; if STRING lpstr passed a pointer to the string, I'd have expected STRING @ lpstr to pass a pointer to the pointer. Since both pass the same thing, the syntax seems inconsistant.

Ed
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform