Solved

Converting LPBYTE for use with _tcsstr()

Posted on 2007-11-30
2
1,874 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
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

771 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

7 Experts available now in Live!

Get 1:1 Help Now