Use the AllocSysString member function of the CString:
Code:
CString cs("Hello");
BSTR bstr = cs.AllocSysString();
If you pass the 'BSTR' to some OLE function, this will normally free the 'BSTR' memory when done with it.
If you use the 'BSTR' by yourself, dont forget to call '::SysFreeString()' when you're done with it.
Code:
::SysFreeString(bstr);
'BSTR' to 'CString':
You will mostly need this when you have some OLE function that returns a 'BSTR'. Such an OLE Function will basically do something like this: