?
Solved

Search CComBSTR for specified Text.

Posted on 2004-04-15
6
Medium Priority
?
866 Views
Last Modified: 2012-06-27
I need to search a CComBSTR myStr
for the existance of the word "GOTO"

Any suggestions?  Im new to CComBSTR.
Thanks
0
Comment
Question by:Rowdyone52
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 10835797
You'd just search the 'BSTR' member like any regular UNICODE string, e.g.

CComBSTR cb;

//...

__bstr_t bstr ( ( BSTR) cb;)
wchar_t* pwsz = ( wchar_t*) bstr;

if ( wcsstr ( pwsz, L"GOTO)) {

   // string found
}

0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 10835813
BTW, that works for ANSI also:

CComBSTR cb;

//...

__bstr_t bstr ( ( BSTR) cb;)
char* psz = ( char*) bstr;

if ( strstr ( psz, "GOTO)) {

  // string found
}


'__bstr_t' is a powerful little helper class.
0
 

Author Comment

by:Rowdyone52
ID: 10835821
thanks jkr..

does GOTO need quote surrounding or just the one?

Greg
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 86

Expert Comment

by:jkr
ID: 10835822
Argh, forgot the closing double quote for the "GOTO" string literal :o)

CComBSTR cb;

//...

__bstr_t bstr ( ( BSTR) cb;)
char* psz = ( char*) bstr;

if ( strstr ( psz, "GOTO")) {

 // string found
}
0
 
LVL 86

Expert Comment

by:jkr
ID: 10835827
Well, seems you found the problem with the closing quote already *g*
0
 

Author Comment

by:Rowdyone52
ID: 10835828
that answers my ?

thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 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 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.
Suggested Courses

650 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