简体   繁体   English

可变存储位置 - 最佳实践?

[英]Variable Storage Location - Best Practice?

I'm trying to learn how to be better at storing my variables outside of the current application in which I'm working.我正在尝试学习如何更好地将我的变量存储在我正在工作的当前应用程序之外。 I mostly work in building add-ins for applications such as Excel's VBA and DraftSight's AutoLisp , and most of my work doesn't require me to store anything outside of these applications.我的主要工作是为 Excel 的VBA和 DraftSight 的AutoLisp等应用程序构建插件,而且我的大部分工作不需要我在这些应用程序之外存储任何内容。 There have been a few insistence where I've needed to store settings outside of these two applications.有一些坚持认为我需要在这两个应用程序之外存储设置。

To help narrow the scope of what I'm asking, I'm wanting to learn about storing application and add-in variables in the Windows OS, for personal machines.为了帮助缩小我所问的范围,我想了解如何在 Windows 操作系统中为个人机器存储应用程序和加载项变量。

Questions问题

  1. Where should variables be place in which directories?变量应该放在哪个目录中? Categories would be helpful.类别会有所帮助。
  2. What file extension(s) should be used to save the variable information?应该使用什么文件扩展名来保存变量信息?
  3. If a variable contained sensitive information, how and where should that information be stored?如果变量包含敏感信息,该信息应如何存储以及存储在何处?
  4. If an application lacks a dedicated place to store add-in files for itself, where should the add-in file be best placed?如果一个应用程序没有一个专门的地方来为自己存储插件文件,那么插件文件应该放在哪里最好?

Store important per-user data in %appdata% and unimportant data in %localappdata% .将重要的每个用户数据存储在%appdata%中,将不重要的数据存储在%localappdata%中。 The Shell.NameSpace scripting method should let you access these in VBA. Shell.NameSpace脚本方法应该允许您在 VBA 中访问这些。

You can see a list of all the special locations on MSDN .您可以在 MSDN 上查看所有特殊位置的列表。 Simple settings can be stored in the registry instead.简单的设置可以存储在注册表中。

You get to decide the file extension.您可以决定文件扩展名。

If you have proper access to the Windows API you can call CryptProtectData to store encrypted data.如果您有权访问 Windows API,则可以调用CryptProtectData来存储加密数据。

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

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