6

I've been using the usual My.Settings... method when it came to saving settings for my program but I was just wondering, If I wanted to save program settings into the Registry and load those settings, are there any benefits when comparing with saving settings to a custom written file and loading those settings from the file.

Which would you prefer and why?

Zer0
  • 185

3 Answers3

7

A good starting point is Jeff Atwood's article: Was The Windows Registry a Good Idea?

It gives a lot of good reasons not to use the registry. Among them:

  • The registry is a single point of failure. That's why every single registry editing tip you'll ever find starts with a big fat screaming disclaimer about how you can break your computer with regedit.
  • The registry is opaque and binary. As much as I dislike the angle bracket tax, at least XML config files are reasonably human-readable, and they allow as many comments as you see fit.
  • The registry has to be in sync with the filesystem. Delete an application without "uninstalling" it and you're left with stale registry cruft. Or if an app has a poorly written uninstaller. The filesystem is no longer the statement of record-- it has to be kept in sync with the registry somehow. It's a total violation of the DRY principle.
  • The registry is monolithic. Let's say you wanted to move an application to a different path on your machine, or even to a different machine altogether. Good luck extracting the relevant settings for that one particular application from the giant registry tarball. A given application typically has dozens of settings strewn all over the registry.

Probably the only applications that may require the registry are:

  • COM applications. Without a central repository it'd be much harder to get the class ID (CLSID)
  • large scale applications that need to administer the configuration network-wide (storing the data in the registry gives you the possibility to use Admin Templates in a Group Policy).
manlio
  • 4,256
3

I would suggest that the Windows Registry is best left to Windows itself to play with.

  • Parts of it are inaccessible to regular users.
  • Parts of it are inaccessible to certain types of application (32-bit processes running on 64-bit versions of Windows).
  • It's a completely proprietary storage mechanism, which can change, without warning, with any upgrade or security patch.
  • It's not easy to backup or restore parts of the Registry; it's really all or nothing.
  • Values held therein aren't portable; they're fixed onto one particular machine.

Contrast that with a simple, text file held in the user's Roaming profile directory:

They are accessible to the user (with no security or U.A.C. complications), the format and content of that file are completely under your control, they get captured by a regular, file system backup, they can get carried, seamlessly, onto every machine that the user logs onto and they're less likely to get lost if you have to reinstall your operating system.

Phill W.
  • 13,093
1

In the distant past, I would have suggested using the registry (as opposed to an INI file). These days, I would lean toward file-based storage of settings and configuration. The user-changeable parts of the settings should be persisted using the Isolated Storage API.

OldFart
  • 199