Root
Root

Reputation: 309

What options do I have for storing information on Windows? How should I read this information?

what options I have for storing information on Windows?

I was thinking of creating a file or working with the registry but the file could get rather annoying to handle if it gets too big and the registry is a bit too easily accessible by the user.

I don't expect there to be more than a max of 100 entries and they would look something like this.

John Banana

Marcus Apple

etc.

I realize this wouldn't produce a too big file but I dont want to parse it everytime I need the information. I was thinking of reading the information into the application on startup but wouldn't that create performance issues? Or perhaps it's so little it wouldn't matter except for older computers? Are there any other options? Perhaps I could encrypt the information and put it in the registry? Is the registry suitable for putting multiple entries such as this?

Note that when I program I sometimes go a bit too overboard when it comes to making things efficient. Excuse my ignorance.

Upvotes: 2

Views: 137

Answers (1)

aps2012
aps2012

Reputation: 1612

You asked What options do I have for storing information on Windows? Basically, there are three main strategies:

  1. Use the machine's Registry and use the Registry API to access it.
  2. Use a flat text file in the INI File Format and use the Private Profile String API to access it.
  3. Use a flat text file of your own format and use your own file handling to access it.

Any of these strategies will achieve your goal of storing data.

However, on Windows platforms, there is a more important question you must consider that will give you your answer:

Is the User of my application going to want to move their data to another machine and run my application on that other machine?

If the answer is Yes to the above question, then (2) or (3) will be your answer as moving a file on disk from one machine to another is a simple task. Moving registry entries from machine to machine, on the other hand, is not a simple task for a normal computer user, and neither is the task of coding functions in your application to export registry databases to flat files and re-import them.

Within (2) and (3), (2) is the simplest as Windows has existing APIs to get the contents of the file out for you; (3) requires you to write your own routines. Ultimately, it will be reliant on how you want to structure your data.

If the answer is No to the above question, then any of (1), (2), or (3) is Ok as the user won't care how the data is stored.

None of the above strategies are less or more accessible than any other (if you're worried about user being able to view your data). If your worried about your data being visible then add encryption into the method you finally choose.

Upvotes: 4

Related Questions