Home > Net >  Variable Storage Location - Best Practice?
Variable Storage Location - Best Practice?

Time:06-18

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. 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.

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?

CodePudding user response:

Store important per-user data in %appdata% and unimportant data in %localappdata%. The Shell.NameSpace scripting method should let you access these in VBA.

You can see a list of all the special locations on 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.

  • Related