title: C# Security RegistryPermissions demand popup
body: <p>I have this code but I don't seem to understand exactly the purpose of the permission Demand method</p>
  
  <pre><code> RegistryPermission registryPermission = new RegistryPermission(RegistryPermissionAccess.AllAccess, @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
  registryPermission.Demand();
  
  RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", RegistryKeyPermissionCheck.ReadWriteSubTree);
  if (checkBoxLoadStartup.Checked)
  {
       //make an entry in the registry to make this program run at start up
       regKey.SetValue(Application.ExecutablePath.ToString(), Application.ExecutablePath.ToString());
  }
  else
  {
      //delete the entry
      regKey.DeleteValue(Application.ExecutablePath.ToString());
  }
  </code></pre>
  
  <p>I expected to see a window popping up and asking me to allow the permissions to write the registry. Instead I got an exception. To make it work I added:</p>
  
  <pre><code>&lt;requestedExecutionLevel level="requireAdministrator" uiAccess="false" /&gt;
  </code></pre>
  
  <p>in app.manifest and now I don't see any popups but I'm allowed to change the values.</p>
  
  <p>Is it possible to show a popup asking a question to give permissions to change the registry and based on the given permissions to modify or not the registry key?</p>