Solved

Converting LPBYTE for use with _tcsstr()

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

828 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