I am working with an application once written for Windows XP, making it work for Windows Vista and later. Formerly there was a lot of read and write accesses to HKEY_LOCAL_MACHINE
in registry. I've rewritten this so that only the installer writes to HKEY_LOCAL_MAHINE
(with elevated privileges) and the application accesses these settings with read-only access. The application is written in C# and C++ and compiled for 32 bit.
Everything is working fine on my development computer running Windows 7. I have also tested the installer and application an a clean (virtual) Windows 7, both as a local administrator and a normal user. It just works. But when I test the installer and application on another computer (also running Windows 7 as a local administrator) I get the following exception:
System.Security.SecurityException: Requested registry access is not allowed.
The exception is thrown by the RegistryKey.OpenSubKey(string)
method which according to Microsoft retrieves a subkey as read-only which I thought should be ok.
I have tried following all the rules and recommendations when it comes to registry accesses on Windows Vista and later, but it seems that I still miss something. What am I missing here?