Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BSTR and _bstr_t

Status
Not open for further replies.

zyhu

Programmer
Aug 22, 2000
21
0
0
CN
What's the relationship between the BSTR and the _bstr_t?
How can I convert the BSTR to the _bstr_t? Vice versa?

Thanks for your help.

zyhu@ms.mmit.stc.sh.cn
 
My answer assumes that you are using Microsoft Visual C++.

_bstr_t is just a wrapper class for BSTR. It provides some useful operators and methods.

You can construct a new _bstr_t object form a BSTR, for example:

function example(BSTR input)
{
_bstr_t my_object(BSTR);
}

You can extract a BSTR from a _bstr_t using the copy() method, for example

function example2 (_bstr_t input)
{
BSTR my_new_object = input.copy();
}

For more information, look up _bstr_t in the MSDN library or look at the Visual C++ Header File comutil.h.

Hope that helps! [sig]<p>Pat Gleason<br><a href=mailto:gleason@megsinet.net>gleason@megsinet.net</a><br><a href= > </a><br> [/sig]
 
I've looked up the msdn and tested the function: _bstr_t( BSTR bstr, bool fCopy ) throw ( _com_error ). I've also looked the comutil.h to see how the class _bstr_t is defined. But I still failed to convert the BSTR to _bstr_t.
Every time when I convert the BSTR to _bstr_t, the m_str of the _bstr_t shows CXX0030:Error:expression cannot be envaluated. Why? What's the function of m_str in the class _bstr_t? Please help me. If I don't solve this problem, I cann't go forward my job.
zyhu
zhiyuan_hu@hotmail.com
[sig][/sig]
 
Hello,
_bstr_t is a wrapper class for BSTR.This class has a constructor which takes the BSTR as a parameter....

class has a function called copy via which u can have a copy of encapuslated BSTR...


Dinesh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top