How I can convert LPBYTE to char [256]?
When I read from Windows registry value:
blah REG_SZ "blah some text"
char value[256];
DWORD keytype = REG_SZ;
DWORD dwCount = sizeof(value);
RegQueryValueEx((HKEY)key, "blah", 0, &keytype, (LPBYTE)&value, &count);
cout << "Read text from registry: " << value << endl;
after cout this it shows (screenshot):
http://i33.tinypic.com/dnja4i.jpg
(normal text + some signs)
I must compare value from registry:
if("blah some text" == value)
cout << "Kk, good read from registry\n";
How I can convert this LPBYTE value to char[256] ?
From MSDN:
After querying the value, you should set value[dwCount-1] to '\0' to ensure it is null terminated.
Or just use RegGetValue which removes a lot of the oddness in the registry API - guarantees null terminated strings, allows you to specify the expected data type and fail if it is otherwise, automatically expands REG_EXPAND_SZ's, etc.