VARIANT convertions [modified]
-
i have a variable whose type is long*. i wanna assign it to a CComVariant variable. //put value into variant CComPtr< IMyInterface > spInter; long *p = (long*)spInter.p; CComVariant vt; vt.plVal = spInter.p; //how to get value from variant CComPtr< IMyInterface > spNew; spNew = (IMyInterface*)vt.plVal; (i can do this because i know the value type in variant, but how could i do if i don't know the type? should i call changetype() first?but what should i pass into ChangeType(???) as parameter? -- modified at 1:18 Wednesday 16th August, 2006
-
i have a variable whose type is long*. i wanna assign it to a CComVariant variable. //put value into variant CComPtr< IMyInterface > spInter; long *p = (long*)spInter.p; CComVariant vt; vt.plVal = spInter.p; //how to get value from variant CComPtr< IMyInterface > spNew; spNew = (IMyInterface*)vt.plVal; (i can do this because i know the value type in variant, but how could i do if i don't know the type? should i call changetype() first?but what should i pass into ChangeType(???) as parameter? -- modified at 1:18 Wednesday 16th August, 2006
-
i have a variable whose type is long*. i wanna assign it to a CComVariant variable. //put value into variant CComPtr< IMyInterface > spInter; long *p = (long*)spInter.p; CComVariant vt; vt.plVal = spInter.p; //how to get value from variant CComPtr< IMyInterface > spNew; spNew = (IMyInterface*)vt.plVal; (i can do this because i know the value type in variant, but how could i do if i don't know the type? should i call changetype() first?but what should i pass into ChangeType(???) as parameter? -- modified at 1:18 Wednesday 16th August, 2006
You should pass COM interfaces at
VT_UNKNOWN
orVT_DISPATCH
so they get properly marshaled if necessary.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
You should pass COM interfaces at
VT_UNKNOWN
orVT_DISPATCH
so they get properly marshaled if necessary.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
thanks guys, here is my situation. i have a class which hold a tree control(activex control), sure tree control offer setItemData(item, data), getITemData(item, &data); here data's type is converted to long*. i wanna store the interface pointer address in the item data, and get it back when i need. VARIANT DelegateGetData(item) { long *data; getItemData(item, data); CComVariant vt; vt.plVal = data; return vt; } CComVariant vt = DeletgateGetData(item); CComPtr spData((IMyInterface*)vt.plVal);//it there any better way here???