在Win32 Delphi应用程序中存储用户首选项和设置的最佳实践是什么? [英] What are the best practices for storing user preferences and settings in Win32 Delphi applications?

查看:74
本文介绍了在Win32 Delphi应用程序中存储用户首选项和设置的最佳实践是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Delphi Win32应用程序中存储用户首选项(颜色,工具栏的开/关,面板宽度(以像素为单位))和应用程序设置(最后10个文件,默认保存目录,默认打开目录).最佳做法是什么?

I want to store user preferences (colors,toolbars on/off, panel widths in pixels) and application settings (last 10 files, default save directory, default open directory) within my Delphi Win32 application. What is the best practice for doing this?

推荐答案

您有两个主要选择:

  1. 将设置存储在用户配置文件下的文件中.如果您的设置足够简单,那么INI文件就可以正常工作.
  2. 将设置存储在注册表中的HKEY_CURRENT_USER下,这也是配置文件的一部分.
  1. Store the settings in a file under the user profile. If your settings are simple enough then INI files work perfectly adequately.
  2. Store the settings in the registry, under HKEY_CURRENT_USER which is also part of the profile.

我个人更喜欢使用注册表,因为它免费提供分层存储.如果使用文件,则必须自己做,这可以绑定更复杂的数据.

Personally I prefer to use the registry since it provides hierarchical storage for free. If you use a file, then you have to do that yourself which can be a bind for more complex data.

另一方面,如果您想编写一个便携式应用程序(即可以驻留在记忆棒上的应用程序),那么可以使用位于可执行文件旁边的用户设置文件.

On the other hand, if you want to write a portable app, i.e. one that can live on a memory stick, then a user settings file that sits alongside the executable is the way to go.

这篇关于在Win32 Delphi应用程序中存储用户首选项和设置的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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