After running the following codes in a 32-bit process, the % ProgramFiles% data is 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));
Result
<- What the hell. Who is expanding it?
I do not want to convert the data. -But I have to use the REG_EXPAND_SZ type .
How do i do
source
share