Solved

How to convert from CString to BSTR

Posted on 2004-04-16
2
1,221 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 125 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Writing a parser for java language 4 83
FMX enumerated colours 2 117
C++ standard library based binary archive format 6 104
C++ mouse_event mouse look 7 97
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

828 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