Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to store program settings instead of HKEY_LOCAL_MACHINE?

I have some program settings that are currently stored in HKEY_LOCAL_MACHINE. Due to Vista and locked down users, some users don't have permission to HKEY_LOCAL_MACHINE, and those values don't really belong to HKEY_LOCAL_USER either (it has to be the same for all users), what's the best alternative location for storing these?

Majority of settings are stored in the DB already, but there are some that the program needs to know about before connecting to the DB. Ideally I'll like a way to implement this without needing to check what operating system is running.

This is for a desktop app written in Delphi.

like image 359
Robo Avatar asked Nov 12 '08 20:11

Robo


People also ask

Does Hkey_current_user override HKEY_LOCAL_MACHINE?

After testing, unless it's explicitly set at the system level via Group Policy, removing user editing ACL from the HKCU key, etc., HKCU will be honored over HKLM (simply adding the HKLM key doesn't cause precedence).

Where are GPO settings stored in registry?

The registry keys are found in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System.

What information is stored in HKEY_LOCAL_MACHINE?

The HKEY_LOCAL_MACHINE, otherwise known as HKLM, is a Windows Registry tree that contains configuration data that is used by all users in Windows. This includes information about Windows services, drivers, programs that automatically run for every user, and general OS settings.

What does the registry key HKEY_LOCAL_MACHINE hold the settings for?

HKEY_LOCAL_MACHINE (HKLM) Abbreviated HKLM, HKEY_LOCAL_MACHINE stores settings that are specific to the local computer. The key located by HKLM is actually not stored on disk, but maintained in memory by the system kernel in order to map all the other subkeys. Applications cannot create any additional subkeys.


1 Answers

You should put:

  • personal settings (like window position and minor preferences) under HKEY_CURRENT_USER in the registry or in the CSIDL_APPDATA or CSIDL_LOCAL_APPDATA folder;
  • important application settings (like a fixed path that should not be modified by your users) under HKEY_LOCAL_MACHINE in the registry or in the application's folder. Set them at install time, when administrator privileges are available;
  • shared data (data that all of your users should read and write to, like a simple database) in the CSIDL_COMMON_APPDATA folder.

Use SHGetFolderPath to find the location of the CSIDL_* folders.

Depending on your needs you might like to implement all three options given at once. There would be nothing wrong with it.

like image 157
Rômulo Ceccon Avatar answered Oct 06 '22 00:10

Rômulo Ceccon