Windows 64-bit registry - why is% ProgramFiles% converted to% ProgramFiles (x86)%?

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
enter image description here <- 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

+3
source share
1 answer

WOW64 Registry Virtualization. 2003 Vista, Win7 ( ). , 64- 32- ? ( , )

+3

Source: https://habr.com/ru/post/1787607/


All Articles