|
Hi,I want to write registry with Non - administrator account In MFC(vs2010),but failed.Can you have any idea to write registry.
|
|
|
|
|
There is a reason that parts of the registry can be only changed by administrators. To store user dependant information use the HKCU (current user) tree where you can write with user privileges.
|
|
|
|
|
In win7 ,When open UAC,it also cannot write registry,how
to avoid
|
|
|
|
|
The registry is like a file system with different access rights for the different keys. Navigate to your key using regedit and open the 'Permissions' command from the context menu to see the permissions for specific users and groups. Some keys have restricted access even for administrators (SAM, SECURITY). Such keys can be only accessed by the SYSTEM user.
So the answer to your question is: You must have the access rights which are usually granted when you open the key using the account of the key's owner.
|
|
|
|
|
HKEY_CURRENT_USER also cANNOT write
|
|
|
|
|
At the moment I know only two reasons for denied permissions when trying to write to HKCU:
- Using
RegOpenKeyEx() , the key was not opened with the KEY_SET_VALUE or KEY_WRITE access right. - Using
RegOpenKey() instead of RegOpenKeyEx() .
Regarding the second reason I will cite the MSDN:
Quote: The RegOpenKey function uses the default security access mask to open a key. If opening the key requires a different access right, the function fails, returning ERROR_ACCESS_DENIED. An application should use the RegOpenKeyEx function to specify an access mask in this situation.
If this does not solve your problem, you should show us the code that fails (including the RegOpenKeyEx() call).
|
|
|
|