Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Receiving an array from COM server
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01484052
Message ID:
01484221
Views:
37
>>>>>I have a COM server that has a method that returns a pointer to float in a Variant.
>>>>>
>>>>>The pointer to float is actually an array of 32-bit floats.
>>>>>
>>>>>Is there some way that I can get access to that array in VFP?
>>>>>
>>>>>Thanks,
>>>>>Jim
>>>>
>>>>You may need to use COMARRAY() to specify if it is zero based etc.
>>>>
>>>>ie:
>>>>
>>>>local array aMyArray[1] 
>>>>COMARRAY(oMyCOM,11)
>>>>oMyCOM.MyMethod(@aMyArray)
>>>>
Cetin
>>>
>>>Cetin,
>>>
>>>thanks for your quick reply.
>>>
>>>The COM object method returns the pointer like so:
>>>
>>>pArray = oMyCom.GetDataArray()
>>>
>>>How can COMARRAY help me with this?
>>>
>>>Thanks,
>>>Jim
>>
>>A follow-up.
>>
>>If I connect to the COM server using a C++ client, pArray is the address of the array in the COM server. I can view and manipulate all of the elements in the array.
>>
>>I would like to be able to do the same thing with a VFP COM client.
>>
>>How can I do this?
>>
>>There is a lot of VFP documentation about how to write a COM server, but very little about COM clients and passing data between the client and server.
>>
>>Thanks,
>>Jim
>
>Some additional thoughts:
>
>1. oMyCOM.GetDataArray() actually returns a variant. The address of the array is contained in the pfltVal member. So, in my C++ client, I can get access to the array with:
>
>pData = (oMyCOM.GetDataArray()).pfltVal
>
>2. The VFP documentation explains about the need to use the Comarray() function when passing an array TO a COM object. But, says nothing about how to receive an array from a COM object.
>
>If I try in VFP:
>
>LOCAL vaData AS Variant
>vaData = oMyCOM.GetDataArray()
>pData = vaData.pfltVal
>
>The debugger shows vaData = .NULL. and the Type is "N"
>
>and I get an error message saying "VADATA is not an object."
>
>Thanks for your help.
>Jim

Well, I have figured out the answer to my problem. If I create my array as a SAFEARRAY in my COM server, and pass that in the variant returned by GetDataArray(), VFP correctly receives the array.

Jim
Previous
Reply
Map
View

Click here to load this message in the networking platform