Hello,
first,I am new to c++. Im open to comments.
I have to send an VARIANT array to a com api but i can't make it work.
I saw somewhere that using SAFEARRAY should work, but I can't find how to use it for the IxPtr type. (see below)
//--
IxPtr element1;
IxPtr element2;
IxPtr element3;
SAFEARRAYBOUND aDim[1];
aDim[0].lLbound= 0;
aDim[0].cElements= 3;
SAFEARRAY FAR* Array1= SafeArrayCreate(VT_VARIANT,1,aDim);
long aLong[1];
aLong[0]=0;
SafeArrayPutElement(Array1, aLong, element1);
aLong[0]=1;
SafeArrayPutElement(Array1, aLong, element2);
aLong[0]=2;
SafeArrayPutElement(Array1, aLong, element3);
vTemp.vt = VT_ARRAY|VT_VARIANT;
vTemp.parray = Array1;
com->SetArray(&vTemp); //VARIANT * array
//---
I also have the VB translation of the API SetArray call:
//-
com.SetArray Array(element1, element2, element3)
//-
How can it be so difficult to convert this unique VB line into c++ ?
Thanks in advance
Jo
first,I am new to c++. Im open to comments.
I have to send an VARIANT array to a com api but i can't make it work.
I saw somewhere that using SAFEARRAY should work, but I can't find how to use it for the IxPtr type. (see below)
//--
IxPtr element1;
IxPtr element2;
IxPtr element3;
SAFEARRAYBOUND aDim[1];
aDim[0].lLbound= 0;
aDim[0].cElements= 3;
SAFEARRAY FAR* Array1= SafeArrayCreate(VT_VARIANT,1,aDim);
long aLong[1];
aLong[0]=0;
SafeArrayPutElement(Array1, aLong, element1);
aLong[0]=1;
SafeArrayPutElement(Array1, aLong, element2);
aLong[0]=2;
SafeArrayPutElement(Array1, aLong, element3);
vTemp.vt = VT_ARRAY|VT_VARIANT;
vTemp.parray = Array1;
com->SetArray(&vTemp); //VARIANT * array
//---
I also have the VB translation of the API SetArray call:
//-
com.SetArray Array(element1, element2, element3)
//-
How can it be so difficult to convert this unique VB line into c++ ?
Thanks in advance
Jo