简体   繁体   English

如何基于每个用户保存用户设置?

[英]How can I save user settings on a per user basis?

I'm working on a program that needs a feature that has similar functionality as a contact list. 我正在开发一个程序,它需要一个功能与联系人列表类似的功能。 I need to have user settings, but I don't know how, if it's even possible, to create application settings in code. 我需要有用户设置,但我不知道如果可能的话,在代码中创建应用程序设置。

I would like to be able to add as many new "contact" settings as needed, so I figured if I couldn't create new settings, I should just have one setting that is a list, but that also doesn't seem to be possible. 我希望能够根据需要添加任意数量的新“联系人”设置,所以我想如果我无法创建新设置,我应该只有一个设置是列表,但似乎也不是可能。 I've looked around on here and Google and can't find anything to fit my needs. 我在这里和谷歌一起环顾四周,找不到符合我需求的东西。

Requirements: Store contact-like data such as phone numbers, email addresses, etc. Be able to add as many of these contact settings as needed. 要求:存储类似联系人的数据,如电话号码,电子邮件地址等。能够根据需要添加尽可能多的联系人设置。 Everything in one executable file. 一个可执行文件中的所有内容。

Edit: So there's the object data type, which seems to fit my needs. 编辑:所以有对象数据类型,这似乎符合我的需要。 Is there a reason this wasn't an answer to any of the very similar questions to mine? 有没有理由这不是我的任何一个非常相似的问题的答案? It seems to be perfect.. 它看起来很完美..

Edit: Nevermind, seems to be compiler errors when trying to access a property of my object because it doesn't have that property until it's an instance of my own objects... 编辑:Nevermind,在尝试访问我的对象的属性时似乎是编译器错误,因为它没有该属性,直到它是我自己的对象的实例...

While it is pedantic, I'm not sure a contact list should really be considered as 'settings'. 虽然很迂腐,但我不确定联系人列表是否应该被视为“设置”。 It's really data. 这真的是数据。 As such, it might be better to store this data in an XML file or similar. 因此,将此数据存储在XML文件或类似文件中可能更好。

With JayP. 与JayP。 Sql Server Compact might also be a possibility, it creates a local 'mini' database, without the need of a sql server installation. Sql Server Compact也可能是一种可能,它创建了一个本地“迷你”数据库,而无需安装SQL Server。

Let me add my 2 coins. 让我加上我的2个硬币。 The data the @Walkerneo is talking about is not "settings" data. @Walkerneo所讨论的数据不是“设置”数据。 It's real data that should be considered in other way. 它应该以其他方式考虑它的真实数据。 I would suggest to separate them into 2 parts: real data and real settings. 我建议将它们分成两部分:真实数据和真实设置。

  1. The best place for real data is DB. 真实数据的最佳位置是DB。 It may be Firebird or MS SQL Compact or something else. 它可能是Firebird或MS SQL Compact或其他东西。
  2. As for settings the Registry is a good place. 至于设置,注册表是一个好地方。 At least Qt that is cross platform language uses this approach for Win apps 至少Qt是跨平台语言,对Win应用程序使用这种方法

.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM