Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More string hassles

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
0
0
US
I'm trying to get the output of RegQueryValueEx into a LPTSTR, and it's not going well... here's what I have

Code:
LPTSTR _szExecutable;
unsigned char buffer[MAX_PATH];
...
RegQueryValueEx(hKey, TEXT("executable"), NULL, &datatype, buffer, &bufferlength);
...
????
I've tried a few things, pointers, and casts and TEXT() and such, and nothing seems to do the trick.... I need to actually understand this so I can make it go both ways (I'm later saving values back to the reg and those're getting mucked up too)
 
As per usual I solved it right after I posted..

Code:
LPTSTR _szExecutable;
TCHAR buffer[MAX_PATH];

RegQueryValueEx(....., (LPBYTE)buffer)...);

_szExecutable = _tcsdup(buffer); //cause I'm in a function and otherwise it points to a local variable which gets destroyed.
 
Sometimes just asking the question helps you see the answer...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top