olegsp
asked on
Creating HKEY_LOCAL_MACHINE entry
I need to create a registry entry in HKEY_LOCAL_MACHINE, which, in addition to its default properties, can be read by any user (including the restricted users). I am using CRegKey class with the following options
lResM = regKeyM.Create(HKEY_LOCAL_ MACHINE, _T("Software\\Something"), REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS | KEY_READ | KEY_WRITE);
if(lResM==ERROR_SUCCESS)
{
lResM = regKeyM.QueryStringValue(p Name, sValue, &dwSize);
}
Works fine for admins and power-users, but returns lResM=5 for restricted users (Windows XP), meaning "access denied". How can I read from this registry entry under restricted account?
lResM = regKeyM.Create(HKEY_LOCAL_
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS | KEY_READ | KEY_WRITE);
if(lResM==ERROR_SUCCESS)
{
lResM = regKeyM.QueryStringValue(p
}
Works fine for admins and power-users, but returns lResM=5 for restricted users (Windows XP), meaning "access denied". How can I read from this registry entry under restricted account?
ASKER
Well, I also want admins and power users to be able to write in this key (and everybody else with restricted rights - just read), so they should have full access. I guess my question is: how do I provide read-only access to this key for restricted users, and full access for power users and admins?
Must work for any version of Windows, using registry.
Must work for any version of Windows, using registry.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By using the appropriate access right. 'KEY_ALL_ACCESS | KEY_READ | KEY_WRITE' is a bit too much, since that's not only write access, but *full* acces.
lResM = regKeyM.Create(HKEY_LOCAL_
REG_OPTION_NON_VOLATILE, KEY_READ);
should be and in fact is sufficiant.