在哪里存储程序设置而不是

在哪里存储程序设置而不是

本文介绍了在哪里存储程序设置而不是 HKEY_LOCAL_MACHINE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些当前存储在 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.

推荐答案

你应该:

  • 注册表中HKEY_CURRENT_USER 下或CSIDL_APPDATACSIDL_LOCAL_APPDATA 文件夹中的个人设置(如窗口位置和次要首选项);
  • 注册表或应用程序文件夹中 HKEY_LOCAL_MACHINE 下的重要应用程序设置(例如不应由用户修改的固定路径).在安装时设置它们,当管理员权限可用时;
  • 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.

使用 SHGetFolderPath 来查找 CSIDL_* 文件夹.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 18:53