Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to pass a VB string to an API
Message
From
01/07/1999 06:45:30
 
 
To
01/07/1999 05:06:53
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00236336
Message ID:
00236351
Views:
11
>>Hi all,
>>
>>I want to use an API which is explicitly written for VB. This API takes a string parameter passed by reference as argument.
>>
>>All other API's explicitly written for VB which do not take strings as argument succeed.
>>
>>By testing with other API's I came to the conclusion these api's failed because of that the stringformat of the parameter
>>

You can use a static buffer allocated in memory outside of VFP to hold the data, and construct a BTR-compatible item in the buffer. You'd need to use something like POINTERS or CLSHEAP to do this. You could pass a pointer to the buffer by reference (declare the item as INTEGER @ in the DECLARE...DLL, and then pass an integer value containing a pointer to the buffer by reference in the call. On return, you'd copy the content of memory pointed to by the integer back into a VFP string variable. POINTERS and CLSHEAP both have functions to allocate, copy from and copy to memory buffers.

>>I know that VB uses an other stringformat (BSTR) than VFP (?)
>>
>>How do I solve this problem ??
>>
>>Regards, Walter
>Walter,
>First I would try to pass string by ref. :
>lcString = "myString"
>myAPICall(@lcString)
>Cetin
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
Reply
Map
View

Click here to load this message in the networking platform