Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to convert BSTR to CString?

232 views
Skip to first unread message

Eric P

unread,
Apr 6, 1999, 3:00:00 AM4/6/99
to
Help....

How can I convert BSTR to CString?

THANKS...

...Eric Poey
eric...@yahoo.com

Dan East

unread,
Apr 6, 1999, 3:00:00 AM4/6/99
to
For a unicode build I believe that you can just assign
it directly. You may have to cast it to TCHAR though,
I don't know for sure.
This is for non-unicode builds:

#include "afxpriv.h"

CString target;
BSTR source; //needs to be initialized with your data

USES_CONVERSION;
target=OLE2T(source);

Dan

Eric P wrote in message <7ecdbd$989$1...@newton.pacific.net.sg>...

Kumar Venkataraman

unread,
Apr 6, 1999, 3:00:00 AM4/6/99
to
Assigning a BSTR to CString automatically invokes the CString(LPCWSTR)
constructor or operator =(). If you want to be more explicit in your
code, you can use the function AfxBSTR2CString() function declared in
afxpriv2.h

Kumar Venkataraman.

kbc...@my-dejanews.com

unread,
Apr 7, 1999, 3:00:00 AM4/7/99
to
Example...
http://tips.kbcafe.com/tips/kb.cgi?terms=bstr+cstring

In article <7ecdbd$989$1...@newton.pacific.net.sg>,


"Eric P" <erci...@yahoo.com> wrote:
> Help....
>
> How can I convert BSTR to CString?
>
> THANKS...
>
> ...Eric Poey
> eric...@yahoo.com
>
>

////////////////////////////////////////
// He went out of his way to be good. //
////////////////////////////////////////

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

0 new messages