Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use Variant to pass array from C++ client to VFP COM
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
How to use Variant to pass array from C++ client to VFP COM
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01505541
Message ID:
01505541
Views:
188
I have created an EXE COM server in VFP that contains a function that accepts an array from the client, and fills that array with data. The array should be an array of byte, but for now, I would be happy if I could get an array of any data type to work.

I have gotten this to work with a VFP client, but not with a C++ client.

When I use a function statement that defines the incoming array as char @, C++ generates a wrapper from the TypeLib of the COM server that says the calling sequence is a VARIANT*. But, this doesn't work.

Today, I thought that since C++ was sending a Variant, I would try declaring the function as follows:
   FUNCTION GetFBDBlob(nFileID AS Integer, aBlobData AS Variant ) AS Integer
This works with the VFP client when I call with a reference to a char array, like so:
   DIMENSION aBlobData[nFileSize] AS char
   nResult = oFBD.GetFBDBlob(nFileID, @aBlobData)
In C++ I use the following code to set up a Variant and pass it to GetFBDBlob
	SAFEARRAY* pSA = SafeArrayCreateVectorEx(VT_UI1, 0, nFileSize, NULL);
	VARIANT vaBlobData;
	VariantInit(&vaBlobData);
	vaBlobData.vt = VT_ARRAY | VT_BYREF | VT_UI1;
	vaBlobData.pparray = &pSA;
	lResult = pFBDDBA->GetFBDBlob(nFileID, vaBlobData);
I have also tried a variation of this:
	SAFEARRAY* pSA = SafeArrayCreateVectorEx(VT_UI1, 0, nFileSize, NULL);
	VARIANT vaBlobData;
	VariantInit(&vaBlobData);
	vaBlobData.vt = VT_ARRAY | VT_UI1;
	vaBlobData.parray = pSA;
	lResult = pFBDDBA->GetFBDBlob(nFileID, vaBlobData);
GetFBDBlob() contains a call to ALEN right at the beginning: ALEN(aBlobData)

While this works in VFP, either of my two formulations in the C++ client gets an error saying "ABLOBDATA is not an array"

I have also modified this so that the VFP COM server is expecting a reference to a Variant. That also works with the VFP client, but not with the C++ client passing a pointer to the Variant.

Surely there must be some syntax that allows me to pass an array by reference into a VFP COM server. Does anyone know what it is?

Or, does anyone know of a strategy that will let me see where this is failing in VFP?

Thanks,
Jim
Next
Reply
Map
View

Click here to load this message in the networking platform