注册表和INI文件,用于存储用户可配置的应用程序设置 [英] Registry vs. INI file for storing user configurable application settings

查看:193
本文介绍了注册表和INI文件,用于存储用户可配置的应用程序设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Windows的新程序员,我不确定应该将用户可配置的应用程序设置存储在哪里.我了解有必要为用户提供一种用户友好的方式来更改应用程序设置,例如编辑" |更改".设置形式或类似形式.但是,在用户单击该表单上的应用"按钮之后,我应该在哪里存储这些值?

I'm a new Windows programmer and I'm not sure where I should store user configurable application settings. I understand the need to provide a user friendly means for the user to change application settings, like an Edit | Settings form or similar. But where should I store the values after the user hits the Apply button on that form?

在Windows注册表中存储设置与将其存储在本地INI文件或配置文件或类似文件中的利弊是什么?

What are the pros and cons of storing settings in the Windows registry vs. storing them in a local INI file or config file or similar?

推荐答案

配置文件的优点:

  1. 容易做.不需要知道任何Windows API调用.您只需要知道您编程语言的文件I/O接口即可.
  2. 便携式.如果将应用程序移植到其他操作系统,则无需更改设置格式.
  3. 用户可编辑.用户可以在程序执行之外编辑配置文件.

注册专家:

  1. 安全.除非他/她了解regedit,否则用户不能意外删除配置文件或破坏数据.然后用户只是在自找麻烦.
  2. 我不是Windows专家,但是我敢肯定,使用注册表使执行Windows特定的其他事情(用户特定的设置,网络管理之类的组策略等)变得更加容易.

如果只需要一种简单的方法来存储配置信息,我建议使用INI或XML作为格式的配置文件.我建议仅在您想摆脱使用注册表的某些特定条件时才使用注册表.

If you just need a simple way to store config information, I would recommend a config file, using INI or XML as the format. I suggest using the registry only if there is something specific you want to get out of using the registry.

这篇关于注册表和INI文件,用于存储用户可配置的应用程序设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆