Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Converting LPBYTE for use with _tcsstr()

Posted on 2007-11-30
2
Medium Priority
?
2,045 Views
Last Modified: 2008-02-01
Hello all, I'm trying to do a string comparison on an LPBYTE buffer and am getting compilation errors. Any ideas?
LPBYTE storeRegValue = NULL;
storeRegValue = new BYTE[255];
........
retCode = RegEnumValue(hKey, i, (LPWSTR)queryValue, &cchValue, 0, &dataType, (LPBYTE)storeRegValue, &dwSize);
	if((_tcsstr((wchar_t *)storeRegValue, "My Docs")) != NULL)
........

Open in new window

0
Comment
Question by:MardukLitzer
[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
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 20385942
The error is in

 if((_tcsstr((wchar_t *)storeRegValue, "My Docs")) != NULL)

That should be

 if((_tcsstr((wchar_t *)storeRegValue,_T( "My Docs"))) != NULL)

You need to use '_T()' or an L here.
0
 
LVL 86

Expert Comment

by:jkr
ID: 20385987
BTW, you might want to use that the other way round:

wchar_t storeRegValue[255];
........
retCode = RegEnumValue(hKey, i, (LPWSTR)queryValue, &cchValue, 0, &dataType, (LPBYTE)storeRegValue, &dwSize);
        if((_tcsstr(storeRegValue, _T("My Docs"))) != NULL)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

610 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