After running following codes, in 32bit process, the data %ProgramFiles% converted automatically.
HKEY hSubKey;
DWORD dwState;
RegCreateKeyEx(HKEY_CURRENT_USER, L"TestKey", NULL, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, &dwState);
std::wstring data = L"%ProgramFiles%";
RegSetValueEx(hSubKey, L"TestValue", NULL, REG_EXPAND_SZ,
(BYTE*)data.c_str(), (DWORD)(data.size() * sizeof(WCHAR)) + sizeof(WCHAR));
The Result
<-
What the hell. Who expands it?
I don't want to convert the data. -But I have to use type REG_EXPAND_SZ.
How do I do?