First, SysAllocString
accepts const OLECHAR*
, not int
Second, VarBstrCat
's second parameter is BSTR
, not again int
To convert int
to BSTR
, you can do for example like this:
std::wstring s = std::to_wstring(number); // needs C++11
BSTR mybstr = SysAllocString(s.c_str());
UPDATE: Or a bit more efficient, as suggested by Remy Lebeau in comments:
BSTR mybstr = SysAllocStringLen(s.c_str(), s.length());
UPDATE2: If your compiler doesn't support C++11, you can use C function swprintf()
:
wchar_t buf[20];
int len = swprintf(buf, 20, L"%d", number);
BSTR mybstr = SysAllocStringLen(buf, len);