?
Solved

Converting LPBYTE for use with _tcsstr()

Posted on 2007-11-30
2
Medium Priority
?
2,012 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

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 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 learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

770 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