Question

Please suggest me methods for converting from wstring to CComBstr.

I tried to convert like following but it is failing

CComBSTR BstrAddress(strID); // strID is wstring type

I am getting error as "cannot convert parameter 1 from 'std::wstring' to 'int'" Please help me regarding this

Was it helpful?

Solution

These are constructors of CComBSTR class:

CComBSTR( ) throw( ); 
CComBSTR(
   const CComBSTR& src 
);
CComBSTR(
   REFGUID guid 
);
CComBSTR(
   int nSize 
);
CComBSTR(
   int nSize,
   LPCOLESTR sz 
);
CComBSTR(
   int nSize,
   LPCSTR sz 
);
CComBSTR(
   LPCOLESTR pSrc 
);
CComBSTR(
   LPCSTR pSrc 
);

MSDN

So, you could convert like this:

CComBSTR BstrAddress(strID.size(), strID.data());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top