Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know how to assign the contents of a CStringT variable to a BSTR or CComBSTR variable, but how do I go the other way? I have a C++ Com method that includes a BSTR argument. I want to assign the contents of that argument to CStringT, to be able to use CStringT's string manipulation methods before converting back to BSTR and returning. How do I initialize this CString and make the assignment? Please send a code example, if you have one. Thanks!
Posted

This article shows how to do that (as well as other similar conversions):



Another (perhaps better) article that shows how to do this:

 
Share this answer
 
v4
CAtlString str(_T("This is my string!"));
BSTR bstr = str.AllocSysString();
i think this will help u.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900