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

x
?
Solved

Alternative To CComBSTR

Posted on 2006-06-26
3
Medium Priority
?
568 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
ID: 16987186
Try _bstr_t wrapper. Or use SysAllocString API, without any wrappers.
0
 

Author Comment

by:cophi
ID: 16991873
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 2000 total points
ID: 16991915
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

886 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