Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing values to a win32api
Message
From
03/11/1997 19:38:58
 
 
To
03/11/1997 15:58:51
Simon Williams
First Data Merchant Services
Coral Springs, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00058045
Message ID:
00058072
Views:
41
>How can I pass multiple values to a win32api from Visual FoxPro?

You must build a char string that will contain the data (the fields in a structure are always in a contigous memory space, so this is why you can use a char string.)

>Basically I need to fill this structure prior of calling the bind function.
>
> struct sockaddr {
> u_short sa_family;
> char sa_data[14];
> };

Unfortunately, you cannot use this structure directly from VFP (because it contains a pointer (sa_data is a pointer to char, in fact)). The string you must build must have 6 bytes:

- the first 2 bytes: the sa_family in binary format
- the next 4 bytes: a pointer to a string that will contain sa_data

You must use an third-party product (as my Pointers Class that you can download from the Files section) that adds pointer features to VFP, in order to send data to this function.

If you use my Pointers Class:

lnsa_family = ... && Your value
lcsa_data = ... && Your value, max 14 chars
*-- Instantiate a Pointers control object
SET CLASSLIB TO POINTERS ADDITIVE
loPointers=CREATEOBJECT('Pointers')
RELEASE CLASSLIB POINTERS
*-- Convert the sa_family field to binary format on 2 bytes
lcsa_family = loPointers.NumberToWordString(lnsa_family)
*-- Get a pointer to sa_data string
lcpsa_data = loPointers.GetPointer(lcsa_data, "STRUCTURE")
*-- Build the "structure"
lcSockAddr = lcsa_family + lcpsa_data

lcSockAddr is the value that you must pass by reference to the bind function as the 2nd param.

Hope I was clear, :)
Vlad

> int bind (
> SOCKET s,
> const struct sockaddr FAR * addr,
> int namelen
> );
>
>Thanks in advance for your help.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform