General information
Category:
Windows API functions
Sorry about the previous message. I was tired yesterday. George Tasker was right: you can concatenate for this structure:
lnsa_family = AF_INET
lcsa_family = loPointers.NumberToWordString(lnsa_family)
lcSockAddr = lcsa_family + lcsa_data
Sorry once again for pointing you in the wrong direction! :(
Vlad
>>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only