Hi, could anyone help me with the following problem?
I have an ActiveX control developed using Visual Studio 6.0 and it has
a method declared in the .odl file as follows:
void GetEmptyVectorDatumVariantArray(long nNumData, VARIANT*
pVariantArrayRequired);
The body of this method is simply:
SAFEARRAYBOUND sab = {nNumData, 0};
SAFEARRAY* pSaCreated = SafeArrayCreate(VT_R8, 1, &sab);
pVariantArrayRequired->vt = VT_ARRAY | VT_R8;
pVariantArrayRequired->parray = pSaCreated;
So we see that the net result is a method which sets up and returns an
empty safearray.
Now I need to pass a safearray of data to the activex control, so I
have one final method defined in it as foolows in the .odl:
void SetVectorField(VARIANT* vtArrayVectorData, long nNumElements);
the body of this is simply:
SAFEARRAY* psaVectorData = vtArrayVectorData->parray;
double* pRawData = NULL;
SafeArrayAccessData(psaVectorData, (void**)&pRawData);
m_p3DWnd->SetVectorField(pRawData,nNumElements); // Pass data to
another class
SafeArrayUnaccessData(psaVectorData);
SafeArrayDestroy(psaVectorData);
So we see that this simply takes a safearray and passes on the data to
another class.
Finally I call the above to methods in c++ as follows:
VARIANT vtArrayPositions;
VariantClear(&vtArrayPositions);
m_ptrControl->GetEmptyVectorDatumVariantArray(m_nNumTestDatum s,
&vtArrayPositions);
SAFEARRAY* psa = vtArrayPositions.parray;
double* pVectorDatums = NULL;
SafeArrayAccessData(psa, (void**)&pVectorDatums);
for(int nDatum = 0; nDatum < m_nNumTestDatums; nDatum++)
{
pVectorDatums[nIndexBase] = 1.0;
}
::SafeArrayUnaccessData(psa);
m_ptrControl->SetVectorField(&vtArrayPositions,m_nNumTestDatu ms );
So basically I fill the returned empty array with 1's and then pass it
to the activex control.
I all works perfectly - in c++.
QUESTION:
How can I call these two methods from c#?