Solved

Converting LPBYTE for use with _tcsstr()

Posted on 2007-11-30
2
1,896 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
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

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

Suggested Solutions

Title # Comments Views Activity
TCP/IP Socket - connection close results in data lost 14 120
Least Squares Curve Fitting 4 61
Acrinis True image 2 61
delete-remove 14 65
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.

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

12 Experts available now in Live!

Get 1:1 Help Now