Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1270
  • Last Modified:

How to convert from CString to BSTR

I need to pass a CString varaible to a BSTR variable. How do I do that?

The old line was:
BSTR bstr = SysAllocString(L"some text string");

How can I replace the old value to my CString value:
CString str = "abc";
BSTR bstr = ???
0
sungenwang
Asked:
sungenwang
1 Solution
 
jkrCommented:
You could eithre use

CString str = "abc";
BSTR bstr = str.AllocSysString ();

or

CString str = "abc";
BSTR bstr;

str.SetSysString ( &bstr);
0
 
sungenwangAuthor Commented:
That was quick!
I knew this is child play for some of you folks... Thanks!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now