问题描述
我有一些程序设置当前存储在HKEY_LOCAL_MACHINE中。由于Vista并锁定用户,一些用户没有HKEY_LOCAL_MACHINE的权限,并且这些值并不真正属于HKEY_LOCAL_USER(所有用户必须相同),存储这些值的最佳替代位置是什么?
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.
这是用Delphi编写的桌面应用程序。
This is for a desktop app written in Delphi.
推荐答案
您应该:
- 个人设置注册表中 c $ c中的共享数据(所有用户都应该读取和写入数据,就像一个简单的数据库) > CSIDL_COMMON_APPDATA 文件夹。
- 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.
这篇关于在哪里存储程序设置而不是HKEY_LOCAL_MACHINE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!