title: RegCreateKeyEx and RegOpenKeyEx succeeds but RegSetValueEx fails to set value
body: <p>I am trying to set value for a test key under HKCR. RegCreateKeyEx successfully creates the test key and RegOpenKeyEx successfully open the key. RegSetValueEx output <code>ERROR_SUCCESS</code> but doesn't actually write any values. I have been through all similar questions previously asked and the suggestion was that the key would get created under <code>HKLM\SOFTWARE\Wow6432Node</code>. I am on 64-bit win 10 and <code>testkey</code> is under HKCR; there is nothing similar under <code>HKLM\SOFTWARE\Wow6432Node</code>. I tried two different <code>RegSetValueEx</code> and neither works. What am I doing wrong? </p>
  
  <pre><code>HKEY hKey;
  LONG lResult;
  lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "testKey", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &amp;hKey, NULL );
  if(lResult == ERROR_SUCCESS)
      cout&lt;&lt;"Success! Key Created!"&lt;&lt;endl;
  
  lResult = RegOpenKeyEx(HKEY_CLASSES_ROOT, "testKey", 0, KEY_ALL_ACCESS, &amp;hKey);
  if(lResult == ERROR_SUCCESS){
      cout&lt;&lt;"Success! Key Opened!"&lt;&lt;endl;
      const char info[] = "URL:URITest Link\0";
      lResult = RegSetValueEx(HKEY_CLASSES_ROOT,"",0,REG_SZ,(BYTE*) info,strlen(info));
      //lResult = RegSetValueEx(HKEY_CLASSES_ROOT,"URL Protocol",0,REG_NONE,NULL,0);
      if(lResult == ERROR_SUCCESS)
          cout&lt;&lt;"Success! Value Set!"&lt;&lt;endl;
      else
          cout&lt;&lt;lResult&lt;&lt;endl;
  
  }
  </code></pre>
  
  <p>EDIT: See @Remy Lebeau answer below to see where my code was wrong.</p>