views:

185

answers:

6

To me its a no-brainer. The settings for my program go into the Windows Registry. After all, that's what it's for, isn't it?

But some programmers are still hesitant in using the Registry. They state that as it grows it slows down your computer. Or they state that it gets corrupted and causes your computer to malfunction.

So they write their own configuration files, or may use the INI files that Microsoft has depreciated since a few OS's ago.

From what I hear, the problems with the registry that occurred in early Windows OS's were mostly fixed as of Windows XP. It may be the plethora of companies that make Registry Cleaners that are keeping up the rumors that "registry bloat" and "orphaned entries" are still bad.

So I ask, is there any reason today not to use the Windows Registry to store my program configuration settings?

+2  A: 

It depends, when you have small entries that need to read by multiple programs registry is ok, as database have locking issues, and config files are application based.

The problem happens when the user does not allow registry access, that are lots of software in the market that will show a pop up when anyone tries to modify registry and the user can cancel or allow the users. These programs are too common with the anti virus programs.

Priyank Bolia
+8  A: 
  • If the user does not allow registry access, you're screwed.
  • If the user reinstalls Windows and he wants to migrate his settings, it's much more complicated than with a simple file
  • Working with a config file means your app is portable
  • Much simpler for the user to change a setting manually
  • When you'll want to port your app to other OS, what are you gonna do with your registry settings ?
Valentin Rocher
Portable in two senses of the word: First, it's more portable across different platforms, second, the app can be more easily moved around from machine it machine, since the config files will follow it.
Thomi
That's not totally clear - the settings need to be in a per user directory in order to allow the user to change them so the settings will be stored in a location separate from the program. That in turn means that you need to copy *two* things. It's slightly easier than copying out of the registry but you still need to manage your settings separate from your program.
Larry Osterman
You still have to copy the program, even with the registry solution. But it's easier to copy a file.
Valentin Rocher
+2  A: 

Putting your settings into the Registry means that if your user wants to move your program and its settings to another computer, he can't. Backup, ditto. Those settings are in a mysterious invisible place. I find this to be a hostile approach to one's users.

I've written numerous small-to-medium programs, and always used a .ini file. A tech-savy user can edit this file using an editor, he can check the settings in it, he can email it to a tech supporter, he can do a large variety of things that are significantly harder to do with registry entries.

And my programs don't contribute to slowing the computer down.

Carl Smotricz
+2  A: 

Personally speaking, I just don't like binary configuration of any type. I much prefer text file format which can be easily copied, edited, diffed & merged, and put under change control complete with history.

The last of these is the biggest reason not to use the registry - I can stick configuration files into SVN (or similar) with the full support given to text files, instead of having to treat it as a blob.

Jon Ward
+3  A: 

Windows Registry is bloated. Do you really want to contribute to this chaos?

For me, quickly installing, migrating and moving applications is a key point to productivity. I can't if I need to care of hundreds of possible registry keys. If there's a simple .ini or .cfg or .xml file somewhere in my user folder (or even the application directory if it is a portable app), migration is easy.

Often-heard argument pro registry: easy to write and read (assuming you're using plain WinAPI). Really? I consider the RegXXXfamily of functions pretty verbose ... too many function calls and typing work for storing just a few bits of information. So you always end up wrapping the registry away .. and now compare this effort with a simple text configuration file, maybe just key=value-like.

Alexander Gessler
A: 

I don't really have much of an opinion for or against using the registry, but I'd like to note something... Many answers here indicate that registry access may be restricted for a certain user. I'd say the exact same thing goes for config files.

With registry you need to write to the "current user" to be fairly certain about having access (and should do so anyway, in many cases). Config files should be put in a user based area as well (e.g. AppData/Local) if you want "guaranteed" access without questions asked. As far as I know putting config files in "global" areas are as likely to yield access problems as the registry is.

Dentoid