What are the benefits of the registry in Windows?

7

Windows relies a lot on registry to store small pieces of information such as the IP address of the machine. Unix, and so Linux and OS-X, store everything in ordinary files.

When it comes to registry, I see several problems with it:

  • Accessing the information is not that easy. For instance, if the machine fails to boot and I try to solve the issue by mounting the disk on a different machine to access it from a different OS (would it be another Windows or Linux), I can access all the files with ease (with the exception of permissions and encryption), but with registry, although it's theoretically possible to read (and probably change) it, it requires additional applications.

  • Command-line access (in a context where the machine won't boot any longer) is impossible (unless there are apps for that too, but I'm pretty sure installing and using those apps is much more difficult than simply accessing files on disk).

  • Information can be located either in files or in registry, so one has to juggle two locations.

  • Common tools which are used when working with files (such as findstr, the Windows' little brother of grep) are non-existent when working with registry keys.

I'm sure that if Microsoft originally implemented the registry, it was for a good reason and gave (even slight) competitive advantage to Windows over other operating systems of that time.

I thought about performance and space constraints, particularly important at the times Windows was born, but I can't see how storing something in registry improves performance or reduces the space used (storing DWORD as an actual DWORD in registry versus storing its string representation in files will save space, but would that matter that much, even in 1985?

Security-wise, it looks like there is no difference either. I'm not sure if this was the case in 1985, but today's file-based permissions look as—if not more—powerful as the ones implemented for registry keys.

Organization is similar as well: a tree-based structure, with no indexing/searching capabilities (while later versions of Windows implement indexing on files).

So what are or were originally the benefits of registry, compared to storing everything in files?

Arseni Mourzenko

Posted 2015-07-15T08:34:14.777

Reputation: 1 700

2You can use find or findstr ( along with the rest of the command line tools.) together with reg ... for example for /f "tokens=3 usebackq" %a in (\reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer" /v version ^| find "version"`) do echo IE version: %a` – DavidPostill – 2015-07-15T08:59:03.083

1Also the registry can be exported to a plain text file ... reg export ... – DavidPostill – 2015-07-15T09:05:23.587

1To my way of thinking, it's ironic that the Registry is basically just another file-system in it's own right. Keys are like directories, values are like files. I wish MS implemented the Registry as a set of known directories and text files (perhaps under the Windows directory), it would have made things easier. I imagine in the old days of FAT-based storage it wouldn't have been efficient or scalable to do so. – misha256 – 2015-07-15T09:05:57.843

1Registry is a database and this looks like "why everyone uses db instead of xml/ini"? Otherthan not (directly) human-readable, a database/registry is miles ahead of plain text/xml files. You just need a right tool -- a proper PE build. – Chris.C – 2015-07-15T09:29:45.270

Answers

7

Before Microsoft started to use registry, they had INI files (text files). They found very difficult to develop a good platform using only INI files because:

  • It isn't easy to support Unicode.
  • It's a text file, so the permissions are set at the file level, not at the key level. Whoever have access to the file have access to all parameters on it.

  • If two threads are trying to update an INI file simultaneously they can accidentally delete the changes made by the other one.

  • A program can open an INI file in exclusive mode and lock out everybody else.
  • INI files contain only strings. If you want to store binary data, you have to encode it somehow as a string.
  • Parsing an INI file is slow.
  • Central administration of INI files is difficult. Since they can be anywhere in the system, a network administrator can't write scripts to check application status and upgrade the outdated.
  • Systems started to be multi user and keep control of the settings of every user started to be overwhelming. It meant sometimes separated INI files for each user.

Those are the main points that influenced Microsot to look for a new solution, and they came with the registry. The registry is a database, so it resolves the previous problems, but created new:

  • It's a single point of failure.
  • It's binary. In case of damage is very difficult to repair it with your bare hands.
  • Applications that put their settings on registry are less portable.
  • Complex navigation.

Credit to significant source: http://blogs.msdn.com/b/oldnewthing/archive/2007/11/26/6523907.aspx

jcbermu

Posted 2015-07-15T08:34:14.777

Reputation: 15 868

3

You should at least give the source from where you got the information - Why are INI files deprecated in favor of the registry?. Please read How to reference material written by others

– DavidPostill – 2015-07-15T09:21:14.127

2They are statements that were copied word for word without any sort of citation. I have to issue a downvote for that reason. This answer doesn't deserve a single reputation, until the answer's reference material is cited, plagiarism is absolutely not acceptable. When the material is properly quoted and cited I will reverse my vote. – Ramhound – 2015-07-15T10:53:57.477

There is an additional reason which prevents me from upvoting/accepting this answer. You are comparing registry to INI files, while the question is about registry versus file system. You tell that INI files problem “influenced Microsot to look for a new solution”, but the question remains; why inventing something, when there is already a solution (file system) which works well in Unix-based operating systems and solves all the concerns of INI files? – Arseni Mourzenko – 2015-07-16T07:47:10.070

1You really don't want to store a file for every registry value. The overhead (and therefore the time to read and write the info) would be far greater. The minimum size of a file in NTFS is 1 Kbyte for the file record (assuming the file contents can be held there); if the file record isn't enough then it will take 4 KB with the standard cluster size. A registry value otoh needs just 40 bytes of overhead. Also the registry is stored in a B-tree format which makes random access faster. In general the registry is optimized for small pieces of data, while a typical file system is not. – Jamie Hanrahan – 2016-10-03T05:06:37.760