Solved

Alternative To CComBSTR

Posted on 2006-06-26
3
530 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 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.

895 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

15 Experts available now in Live!

Get 1:1 Help Now