title: Reading HKEY_CURRENT_USER under IIS
body: <p>I am trying to read the registry path</p>
  
  <p>HKEY_CURRENT_USER\Software\MyFolder</p>
  
  <p>By running the following code</p>
  
  <pre><code>RegistryKey key1 = Registry.CurrentUser.OpenSubKey(path);
  if (key1 != null)
  {
      RegistryKey key2 = key1.OpenSubKey(subPath);
      if (key2 != null)
      {
          return key2.GetValue(registryKey);
      }
  }
  </code></pre>
  
  <p>Where path = Software and subPath = MyFolder</p>
  
  <ol>
  <li>key2 is always NULL</li>
  <li>I believe this code is actually reading from HKEY_LOCAL_MACHINE\Software\MyFolder because it will default to this under the IIS account (I am running under application pool identity)</li>
  </ol>
  
  <p>How to I force this code to access HKEY_CURRENT_USER? Do I need to change the identity of the app pool? Or some other way?</p>