Read-only access to registry raises security exception

此生再无相见时 提交于 2019-12-11 18:41:06

问题


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?

来源:https://stackoverflow.com/questions/27543321/read-only-access-to-registry-raises-security-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!