Solved

Set registry settings as Admin so that users can access

Posted on 1998-04-29
4
682 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

Industry Leaders: 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 79
Issues with C++ Class 19 106
Embarcadero C++ Builder XE10.1 Berlin red arrow Indicator 2 73
C++ help/ Toy problem 19 52
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

756 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