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.
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).
The registry keys are found in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System.
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.
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.
You should put:
HKEY_CURRENT_USER
in the registry or in the CSIDL_APPDATA
or CSIDL_LOCAL_APPDATA
folder;HKEY_LOCAL_MACHINE
in the registry or in the application's folder. Set them at install time, when administrator privileges are available;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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With