什么是存储应用程序设置的一种相当标准的方式,主要用于Windows,但也易于转移到其他平台。应用程序设置
有基本上4组设置,我想有:
- 全局设置,影响所有用户,并可以机器之间移动
- 全局系统设置,影响所有用户,但具体到该系统(例如默认设置该系统中,例如,图形选项)
- 用户设置,特定于该系统被系统之间移动的用户设置(例如音量)
- 用户系统设置,用户设置(例如,图形选项是依赖于硬件的)
每个级别都会覆盖以前的级别,允许应用程序默认使用“全局设置”,并且用户设置存储用户选择的选项。 前两个基本上是没有用户设置的默认设置(例如对于新用户)。
我认为实现了一套功能,然后我可以为不同的系统实现(可能通过ini文件),但这是最好的方法吗?
(C++)
namespace config
{
void Init(const std::string &AppName);
//updates config for keys/sections that don't exist (ie don't overwrite changes by advanced users by rewriting the entire file)
void Defaults (std::map<std::string,std::map<std::string,std::string> > &Map);
void SystemDefaults (std::map<std::string,std::map<std::string,std::string> > &Map);
void Set (const std::string &Section, const std::string &Key, const std::string &Value);
void SetSystem (const std::string &Section, const std::string &Key, const std::string &Value);
void SetUser (const std::string &Section, const std::string &Key, const std::string &Value);
void SetUserSystem (const std::string &Section, const std::string &Key, const std::string &Value);
std::string GetValue (const std::string &Section, const std::string &Key);
}
我知道Windows有一组这样的设置目录,但这些都是正确的迪尔斯我的需求?
编辑:我宁愿去与文件(ini或xml),而不是使用说窗户注册。然而wheres最好的地方把这些配置文件在每个操作系统下?
在Vista下,我发现这些,这似乎适合我的团体,但什么更旧的Windows版本(我需要支持win2000,XP等),并没有Mac/Linux有自己的simelar文件夹?
- 全局设置 - <SYSDRIVE> \ USERS \ DEFAULT \应用程序数据\漫游
- 全局系统设置 - <SYSDRIVE> \ USERS \ DEFAULT \应用程序数据\本地
- 用户设置 - <SYSDRIVE> \用户\ <USER> \应用程序数据\漫游
- 用户的系统设置 - <SYSDRIVE> \用户\ USER < > \应用程序数据\本地
井文件是我最喜欢的方式,因为相同的东西将在所有平台上工作很少work.The主要问题是文件应该在哪里,以及如何提供一个干净的界面(例如,微软似乎并不需要应用程序在应用程序自己的目录中处理文件... id很满意%username%.ini)。 – 2008-10-16 13:33:00