Hi
I have a question about calling c# COM dll from c++ as below.
This is the method signature of c# COM dll
public object GetData(object[] list, string view)
And this is the method signature when open tlb file from ITypeLib viewver
HRESULT GetData(
[in] SAFEARRAY(VARIANT) list,
[in] BSTR view,
[out, retval] VARIANT* pRetVal);
And this is the c++ code that call the method
SAFEARRAY* a;
SAFEARRAYBOUND aDim[1];
aDim[0].lLbound = 0;
aDim[0].cElements = 1;
a = SafeArrayCreate( VT_VARIANT, 1, aDim);
BSTR data;
wchar_t datawt[100];
char tmp[100]={"TESTDATA"};
mbstowcs(datawt,tmp,100);
data = (BSTR)datawt;
VARIANT vout;
VariantInit(&vout);
vout.vt = VT_BSTR;
vout.bstrVal = data;
HRESULT hr= S_OK;
long index = 0;
if(hr = SafeArrayPutElement(a,&index,&vout))
{
SafeArrayDestroy(a);
}
_variant_t result = k->GetData(a,"VIEW");
I've found there is an object array which has lenght is 1 as the c++ code when COM dll is called but the data in the object array is blank.
Does anyone know why the data is blank and what is the solution for this problem ?
Thx