tags:

views:

23

answers:

2

I would like to convert an int to BSTR. I'm using createTextNode in MSXML which accepts BSTR. How can I do that please?

+1  A: 

Probably not efficient but first convert to a string and then you can simply convert that (untested):

std::wstring convertToString(int value)
{
    std::wstringstream ss;
    ss << value;
    return ss.str();
}

_bstr_t theConverted(convertToString(42).c_str());
graham.reeds
What is Converted on the last line?
Noppanit
I'm sorry but I'm very new to C++
Noppanit
Converted is just a variable name. Call it what you want. Just renamed it to remove any confusion. Also there was a couple of slight bugs to fix.
graham.reeds
A: 

Data Type Conversion Functions [Automation] (MSDN), see "Functions to convert to type BSTR" section.

adf88