Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing values to a win32api
Message
 
To
03/11/1997 17:22:01
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:
00058059
Views:
46
>>>How can I pass multiple values to a win32api from Visual FoxPro?
>>>
>>>Basically I need to fill this structure prior of calling the bind function.
>>>
>>> struct sockaddr {
>>> u_short sa_family;
>>> char sa_data[14];
>>> };
>>>
>>> int bind (
>>> SOCKET s,
>>> const struct sockaddr FAR * addr,
>>> int namelen
>>> );
>>>
>>>Thanks in advance for your help.
>>
>>Simon,
>>
>>Concatenate the values into a single string, then in the declaration, declare it string passed by reference.
>>
>>hth,
>>
>>George
>I already tried that and it didn't work.
>
>sa_family = alltrim(STR(AF_INET))
>sa_data = "129.110.200.92"
>LPaddr = sa_family+chr(0)+ sa_data+chr(0)

The problem may very well be in the definition of sa_family. My C's pretty rusty so if I miss here, please understand. It looks as if the data type is an unsigned short. In order to properly assign that value to a string, you need something like:

lcresult = ""
lnmask = 255
lnvalue = AF_NET
lnbytes = 2
FOR lni = 1 TO lnbytes
lnchar = BITAND(lnvalue, lnmask)
lcresult = lcresult + CHR(lnchar)
lnvalue = BITRSHIFT(lnvalue, 8)
NEXT


lcresult with have the proper value when the loop exits. Concatenate that with your IP address. I do know of one instance where trying to pass a string for a structure doesn't work, but that's with the FoxPro API routines in FOXTOOLS, not Win32API.

hth,

George
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform