Solved

Set registry settings as Admin so that users can access

Posted on 1998-04-29
4
683 Views
Last Modified: 2008-02-01
When an Administrator installs my application I need to install the application's registry settings so that regular users can access the registry settings.

Currently the application's registry settings are in HKEY_CURRENT_USER. When the application is installed by the Administrator the settings are set correctly, BUT when the user logs in (s)/he cannot access the Administrator's HKEY_CURRENT_USER settings.

An alternative solution could be to use HKEY_LOCAL_MACHINE instead. However 'GetAppRegistryKey()' (in APPUI3.CPP in the MFC src) has HKEY_CURRENT_USER hardcoded in. 'GetAppRegistryKey()' is called by various functions in the MFC library. It is conceivably possible to write our own versions of 'GetAppRegistryKey()' and all the functions that call it, but this could be an ardous task, assuming that all the MFC calls to 'GetAppRegistryKey()' are provided in the source.

I am giving this question 75 points because I am assuming that there is standard (and relatively simple) way of dealing with this problem.
0
Comment
Question by:tconway
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:piano_boxer
ID: 1167396
The GetAppRegistryKey() function is not virtual and there for cannot be overridden by your own function.

The best solution for your problem is to manipulate the registry your self. There is some classes for handling the registry on codeguru:

http://www.codeguru.com/misc/registry_ult.shtml
http://www.codeguru.com/misc/registry.shtml



0
 

Author Comment

by:tconway
ID: 1167397
This answer specifies wrappers I could use for the registry, but does not explain how I can prevent MFC classes from using HKEY_CURRENT_USER when I want to use HKEY_LOCAL_MACHINE.

For instance, CControlBarInfo::SaveState() calls CWinApp::WriteProfileString() which in turn calls CWinApp::GetAppRegistryKey(). Therefore I cannot use a CDockState object if I want to use HKEY_LOCAL_MACHINE.

I would also be interested in a solution which allows me to put my settings in HKEY_CURRENT_USER as Administrator and also have those settings available to other users.
0
 
LVL 4

Expert Comment

by:piano_boxer
ID: 1167398
Ahhh..... OK, now I'm with you. I'll look into the problem.
0
 
LVL 1

Accepted Solution

by:
Arkadiy earned 100 total points
ID: 1167399
Here is a suggestion: on setup, write the profile to HKEY_LOCAL_MACHINE. Then, when you run as a user and HKEY_CURRENT_USER does not have the key you expect, copy it from HKEY_LOCAL_MACHINE. This way you have the best of both words. You  can use registry enumeration API so that the registry copying code does not have to know the exat key structure. As an additional benefit, plain users may HAVE to use HKEY_CURRENT_USER  because they do not have writing access to HKEY_LOCAL_MACHINE.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Quicksort a dynamic deque 33 82
Exception thrown at 0x00007FFD5BC81F28 7 61
Embarcadero C++ Builder XE10.1 Berlin red arrow Indicator 2 99
designing in object programming 12 132
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

739 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