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