How to assign an object to a VARIANT in C++?
Posted on 2003-10-28
I am writing a client for a COM dll. In one of the function calls a pointer to an interface is returned (I am using smart pointers)
interfaceOnePtr pInterfacetOne = GiveMeTheVectors();
-Now the returned pointer is need to be passed into another function in the dll. The prototype of that function is:
AddVectors( VARIANT *item);
How can I pass the returned pointer (pInterfaceOne) to the AddVectors method? How can I assign an object to a variant?
I was looking on the internet and didn't find anything straightforward. Is that true that I have to use the VT_DISPATCH ? Right now I am trying this:
v.vt = VT_DISPATCH; // what should I do here instead?
v.pdispVal = pInterfaceOne.Detach();
pOtherInterface->AddVector( &v );
Am I way off? The above code is crashing btw.
Thanks in advance,