[corlib] Fix needing write permission when reading registry values. Fixes #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.
Merge pull request #1445 from meebey/registry_fix_unneeded_write_permission

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