title: Access to the registry key '[KEY_NAME]' is denied
body: <p>I'm writing a small program in Visual Basic 2008 that flips the values of specific DWORDs in a registry key</p>
  
  <p>The registry key in question is:</p>
  
  <pre><code>'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{91801674-82d9-459a-9358-6e5cf3d81d21}\FxProperties'
  </code></pre>
  
  <p>The dword I'm manipulating is "<strong>{e0a941a0-88a2-4df5-8d6b-dd20bb06e8fb},4</strong>"</p>
  
  <p>This is the line of code I wrote to set the DWORD's value is this:</p>
  
  <pre><code>Dim keyString = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{91801674-82d9-459a-9358-6e5cf3d81d21}\FxProperties"
  My.Computer.Registry.SetValue(keyString, "{ad75efc0-8f48-4285-bfa8-40fb036cdab2},2", "00000000")
  </code></pre>
  
  <p>But I get a <strong>UnauthorizedAccessException</strong> at runtime stating that "Access to the registry key [KEY_NAME] is denied."</p>
  
  <p>I ran the program with Administrator privileges, changed the app's manifest to include:</p>
  
  <pre><code>&lt;requestedExecutionLevel level="highestAvailable" uiAccess="false" /&gt;
  </code></pre>
  
  <p>But that didn't work either. So I searched a few forums and tried this:</p>
  
  <pre><code>Dim rkLM As RegistryKey = Registry.LocalMachine
  Dim pRegKey As RegistryKey = rkLM.OpenSubKey("\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{91801674-82d9-459a-9358-6e5cf3d81d21}\FxProperties", True)
  pRegKey.SetValue("{ad75efc0-8f48-4285-bfa8-40fb036cdab2},2", "00000000")
  </code></pre>
  
  <p>But that threw a <strong>NullReferenceException</strong> at me stating "Object reference not set to an instance of an object."</p>
  
  <p>Is there any way I can modify that that key without having to run my program with <strong>SYSTEM</strong> privileges?</p>