Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can a C++ client pass a char array to VFP COM server?
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Can a C++ client pass a char array to VFP COM server?
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01505368
Message ID:
01505368
Views:
115
I'm developing a VFP COM server (EXE) that will read data from a Firebird database and make it available to both VFP and C++ clients. I am having trouble passing the data to a C++ array.


I have a function in the VFP COM server that acceps a FileID and a reference to a char array. It uses the FileID to find the Firebird record and get the data. It then copies the data into the char array. Here is the function definition I am using in the server:
	FUNCTION GetFBDBlob(nFileID AS Integer, aBlobData AS char @) AS Integer
	   EXTERNAL ARRAY aBlobData
This works from a VFP client.

I am unable to get this to work with a C++ client.
I am developing the C++ client using VS2005.
The VS2005 ObjectBrowser shows the following:
Function GetFBDBlob(ByVal nFileID As Long, aBlobData) As Long
I used VS2005 "Add Class from TypeLib" wizard to create a wrapper to call the function. Here is the calling sequence for the wrapper:
	long GetFBDBlob(long nFileID, VARIANT * aBlobData)
Note that the wizard says to pass a pointer to a VARIANT, instead of pointer to char.
So, here is how I set up the call:
	SAFEARRAY* pSA = SafeArrayCreateVectorEx(VT_UI1, 0, nFileSize, NULL);
	VARIANT vaBlobData;
	VariantInit(&vaBlobData);
	vaBlobData.vt = VT_ARRAY | VT_BYREF | VT_UI1;
	vaBlobData.parray = pSA;
	lResult = pFBDDBA->GetFBDBlob(nFileID, &vaBlobData);
Where, pFBDDBA is a pointer to the VFP COM server.
When the program executes the call to GetFBDBlod(), I get a System.AccessViolationException

Surely I am doing something wrong. I have spent many long hours trying various alternatives. I would appreciate your suggestions.
Thanks,
Jim
Next
Reply
Map
View

Click here to load this message in the networking platform