[corlib] Fix needing write permission when reading registry values. Fixe...

...s #25106

ToKey() ignores the setting parameter when calling RegistryKey.OpenSubKey() and
thus always asks for write permission. If you try to read read-only keys (say
HKLM without admin rights) it will fail with a  SecurityException.