Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem sending array to a COM API

Status
Not open for further replies.

Jo004060

Programmer
Sep 25, 2003
18
CA
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top