Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to convert from CString to BSTR

Posted on 2004-04-16
2
Medium Priority
?
1,263 Views
Last Modified: 2010-08-05
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
Comment
Question by:sungenwang
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 10846151
You could eithre use

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

or

CString str = "abc";
BSTR bstr;

str.SetSysString ( &bstr);
0
 
LVL 14

Author Comment

by:sungenwang
ID: 10846230
That was quick!
I knew this is child play for some of you folks... Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question