I have written to code to read and write to registry which is working fine in all the OS except the win2003. Basically after setting value in registry(RegSetValueExW) I am able to read it correctly (RegQueryValueExW). But when i open regedit, i see some junk characters in it.
open using
RegOpenKeyExW(HKEY_LOCAL_MACHINE, subKey , 0, KEY_WRITE | KEY_WOW64_64KEY, &_regKey);
to set: (value is wstring)
::RegSetValueExW(_regKey, key, NULL, REG_MULTI_SZ, reinterpret_cast<const BYTE*>(value.c_str()), static_cast<DWORD>(value.length()*2 + 1));
for query:
::RegQueryValueExW(regKey, key, NULL, &type, reinterpret_cast<LPBYTE>(&value[0]), &valueLength);
From the MSDN manual page on
RegSetValueExW:You need to construct a
BYTEarray containing two terminator characters and pass it to the function.