Link to home
Start Free TrialLog in
Avatar of kamaljeets
kamaljeets

asked on

How to convert char* to BSTR in VC++

can anyone help me out how to use UNICODE string and  converting char* to BSTR
Best regards,

DP
ASKER CERTIFIED SOLUTION
Avatar of Rimvis
Rimvis
Flag of Lithuania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DenL
DenL

Hi kamaljeets, where are you? Several people spent their time giving you, by the way, mostly correct answers, and no reaction from you - not too politely.
Time to CLOSE the question I think? should we give it a few more months?  I think points gets better with time like wine or investments....

If you do close this by new year, I recommend points to RIMVIS, please.
kamaljeets:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
To convert char* to BSTR you can use the following function

BSTR ConvertToBSTR(char* pChar)
{
     return CString(pChar).AllocSysString();
}

and from using unicode strings,
Your CString will be able to handle unicode strings by just putting _UNICODE in the Preprocessor Definitions under Project Settings -> C/C++ -> Preprocessor
and assigning as
CString rName = _T("Test Unicode String");

Hitesh