Re: Prorblem assigning _variant_t to _bstr when _variant_t is an integer



Try

b = (_bstr_t)tvar;

Thanks Stephen that was exactly it! I wonder what .bstrVal is for
though if not for converting to a _bst_t - ah well...

std::cout << b;

That will not work. std::cout does not know about _bstr_t.

actually it does work in the vc7 implementation but I'll make a note
not to do it anyway.

cheers
Karl


Stephen Howe wrote:
if(tvar.vt == VT_NULL) b = "";
else b = tvar.bstrVal;

Try

b = (_bstr_t)tvar;

Any good?
In general, you don't to mess about with the guts of _variant_t and _bstr_t
but instead use the conversion constructors
provided for you.

std::cout << b;

That will not work. std::cout does not know about _bstr_t.
Change that to

std::cout << (const char *)b;

Stephen Howe

.