Solved

Alternative To CComBSTR

Posted on 2006-06-26
3
519 Views
Last Modified: 2008-02-01


I'm basically trying to do this....

i->name = CComBSTR((char *)name);

Without using the CComBSTR method because when I use it with Microsoft Application Verifier it's giving me an error.  So I need another way around it....
0
Comment
Question by:cophi
  • 2
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
Try _bstr_t wrapper. Or use SysAllocString API, without any wrappers.
0
 

Author Comment

by:cophi
Comment Utility
Ok... Should I be using the Detach or CopyTo functions if I'm passing the i pointer(i->name) into another function.  
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
Comment Utility
If another function is supposed to keep BSTR passed to it, use Detach method:

_bstr_t str(name);
OtherFunction(str.Detach());    // now other function is responsible for releasing BSTR
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now