How to pass an array to a ATL-COM object using VARIANTs?
Posted on 1998-11-08
Environment: WIN NT 4 SP3, VisualC++ 5.0 SP2
I want to create a simple function to pass an array from a MFC-EXE to an ATL-COM object.
The function prototype should look like this:
void SetVariantArray(VARIANT varDestArray,
unsigned long lElements);
VARIANT varDestArray is the property inside the ATL-COM object (the VARIANT) I want to set.
void* pSourceArray is the pointer to the Array which I want to pass to the ATL-COM object
e.g.: pSourceArray = new int;
VARTYPE vtType is the base type of the array (the VARTYPE of each element of the array).
e.g.: vtType = VT_I4
unsigned long lElements is the number of elements of the Array
e.g.:lElements = 400;
I'm very new to this stuff, and so I'm very insecure about how such a function should look like.
I read, that I would have to use SafeArrays which I have to create and destroy and pass them via the _variant_t wrapper class, but I dont have any glue about how all these things have to be fit together.
Could someone help me please ?
Many thanks in advance.