Posted on 2004-11-11
Medium Priority
Last Modified: 2013-11-20
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,

     lResM = regKeyM.QueryStringValue(pName, 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?
Question by:olegsp
LVL 86

Expert Comment

ID: 12561982
>>How can I read from this registry entry under restricted account?

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_MACHINE, _T("Software\\Something"), REG_NONE,

should be and in fact is sufficiant.

Author Comment

ID: 12562492
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.
LVL 45

Accepted Solution

AndyAinscow earned 500 total points
ID: 12563638
Try to open with write access, if it fails then the user doesn't have enough rights and then open with read access.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question