MFC client access a VB COM Server with SAFEARRAY argument 
Author Message
 MFC client access a VB COM Server with SAFEARRAY argument

MFC client access a VB COM Server with SAFEARRAY argument
Hi all,

I am writing a personal program and ran into a major ostacle. I tried it for
over and can not figure it out. I would appreciate any comment and help from
you guys.

I am writing a MFC program. This program will interface a vendor program
which ONLY provide VB support. Actually the vendor program was written in VB
obviousely.

I have no problem if the method does not have a SAFEARRAY argument. However,
many methods have SAFEARRAY arguments. Even worse, this program only allow
you to do late-binding, no TLibrary is provided.

For example, one method called
Sub GetAllChartListSorts(SortNames() As String)

Sound simple, but if I write code like this -
OLECHAR FAR* szMember2 = L"GetAllChartListSorts";
hr=m_server.m_lpDispatch->GetIDsOfNames( IID_NULL, &szMember2, 1,
LOCALE_USER_DEFAULT, &dispid);
VARIANT return_val;
EXCEPINFO ExceptionInfo;
unsigned int uArgErr;
DISPPARAMS dp;

VariantInit(&return_val);
//create DISPPARAMS struct
dp.cArgs = 1;
dp.rgvarg = new VARIANTARG;

dp.rgvarg->vt=VT_ARRAY|VT_BSTR;
dp.rgvarg->parray = NULL;

dp.cNamedArgs = 0;
dp.rgdispidNamedArgs = NULL;

//invoke the call
hr = m_server.m_lpDispatch->Invoke( dispid, IID_NULL,
LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD, &dp, &return_val, &ExceptionInfo,
&uArgErr);

The method call return S_OK, but I can find nothing in the DISPARAMS. The
array is not filled up.

The Visual Basic client works just fine.

dim a() as String
Server.GetAllChartListSorts a()

I doubted that the SAFEARRAY might not be properly filled. I verified that
by implementing a COM Server and let a VB client sends a dynamic array
argument. It proves that my way of filling was correct.

However, the code does work. Anything wrong here?



Mon, 13 Dec 2004 06:41:03 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. MFC client access a VB COM Server with SAFEARRAY argument

2. Problem with VB clients accessing SAFEARRAY passed from my ATL server

3. SAFEARRAY access a VB COM Server?

4. Accessing a collection from a VB com server in a VC/ATL Client

5. MFC Client, VB COM Server Question

6. VC++ ATL Server, VB Client, VARIANTs and SAFEARRAYS ??

7. problems passing ADO Recordset from VB-COM client to VC-COM-Server dll

8. Passing a 2D SafeArray from VB client to ATL COM component

9. Need help with a MFC client with SAFEARRAY argument

10. Need help with a MFC client with SAFEARRAY argument

11. Testing a Variant Output argument in ATL Com object using VB client

12. Passing a structure between a VB client and an ATL com server

 

 
Powered by phpBB® Forum Software