RegCreateKeyExW returns error 2 on Windows x64

Solution

Use the KEY_WOW64_64KEY flag

RegCreateKeyExW(hKey, subKey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, 
KEY_READ | KEY_WOW64_64KEY, NULL, &hKeyOut, NULL);