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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a variant of type VT_INT as a function argument

Status
Not open for further replies.

onlyshiza

Programmer
May 14, 2003
18
0
0
US
Hi everyone,

I am calling a method in a COM dll that as the first parameter takes a VARIANT of type VT_INT (actually it has to be like a VARIANT array of (1,0,0), see the following code for more clarification). I am trying to make it work in C++. I have the equivalent working VB code which is like:(in the following code pM is the pointer to an interface)
Code:
dim XVect
XVect = pM.RotateVector(Array(1, 0, 0))
and it works perfect, i.e the Array function in VB does the trick.

Now in C++, I am trying this:
Code:
_variant_t var;
VariantInit(&var);
var.vt = VT_ARRAY | VT_INT;
var.parray= (1,0,0);
//pM is a smart pointer to an interface
pM->RotateVector(&var);
But I am getting an Unknown error on the last line (I have tried it with VARIANT instead of _variant_t as well). Any ideas of what I am doing wrong here? I thought maybe I have to first put my array of (1,0,0) in a safeArray and then assign the safearray to var.parray before passing var to the function. Am I way off?
Appreciate any comments.

onlyshiza

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top