Windows Registry
The Windows Registry is a hierarchical database that stores low-level settings for the Microsoft Windows operating system and for programs that choose to use it. Parts of the computer system, such as the kernel, device drivers, services, Security Accounts Manager, and user interfaces, can all use the registry. It also gives access to counters that help measure how well the computer is working.
Put simply, the registry holds information, settings, options, and other values for programs and hardware on every version of Microsoft Windows. For example, when a program is installed, a new subkey is added to the registry. It can contain details such as where the program is located, its version, and how to start it.
When it was first introduced with Windows 3.1, the registry mainly stored setup information for COM-based parts. Later, Windows 95 and Windows NT used it to gather information that had been spread across many INI files. These files held the settings for single programs and were kept in different places.
Using the registry is not required for Windows programs. For example, .NET Framework programs use XML files for their settings, while portable applications usually keep their settings files together with their executables.
Rationale
Before the Windows Registry, programs stored their settings in INI files. These were simple text or binary files. They were often kept in a shared place, so they did not give each user their own settings. The Windows Registry keeps all application settings in one organized place, although it uses a number of separate files. According to Microsoft, this has several advantages. A binary format can be read and written more quickly. The registry can also store strongly typed data, which is easier to edit by hand. Because each user has their own settings, many people can share one computer. Programs can still work for users who have fewer permissions. The registry can also be reached over a network using the standard set of APIs. This makes backup, restoring, and remote support easier, as long as the Remote Registry service is running and firewall rules allow it.
The registry is a database, so it is more reliable. Features such as atomic updates help keep the data consistent. If two programs try to change the same setting at the same time, one change goes first. This keeps the data correct. With INI files, race conditions could leave data that matched neither change. Windows Vista and later versions can group several registry changes together through the Kernel Transaction Manager. The changes either all succeed or all fail. The NTFS file system also supports this kind of safety. In theory, similar protection could be achieved with ordinary configuration files.
Structure
The Windows Registry stores low-level settings for Windows and for programs that use it. It has two basic parts. Keys work like folders. They can hold values and other keys. Values work like files. They store a name and some data. Key names are case insensitive, and levels are separated by backslashes, similar to Windows path names. Access to keys can be limited by access control lists, so different users and programs may see different parts of the registry. Programs use the Windows API to read and change values. The name "key" can be a bit confusing, because each key works like an associative array.
Even though the registry looks like one connected system, much of it is stored in disk files called hives. The word "hive" is an in-joke. Each user's settings are kept in their own hive, which the system loads when that user logs in. If a user has a roaming profile, that file can be copied to and from a server when they log out and log in. Each registry file also has a transaction log that helps finish any updates that were interrupted.
| Type ID | Symbolic type name | Meaning and encoding of the data stored in the registry value |
|---|---|---|
| 0 | REG_NONE | No type (the stored value, if any) |
| 1 | REG_SZ | A string value, normally stored and exposed in UTF-16LE (when using the Unicode version of Win32 API functions), usually terminated by a NUL character |
| 2 | REG_EXPAND_SZ | An "expandable" string value that can contain environment variables, normally stored and exposed in UTF-16LE, usually terminated by a NUL character |
| 3 | REG_BINARY | Binary data (any arbitrary data) |
| 4 | REG_DWORD / REG_DWORD_LITTLE_ENDIAN | A DWORD value, a 32-bit unsigned integer (numbers between 0 and 4,294,967,295 [232 − 1]) (little-endian) |
| 5 | REG_DWORD_BIG_ENDIAN | A DWORD value, a 32-bit unsigned integer (numbers between 0 and 4,294,967,295 [232 − 1]) (big-endian) |
| 6 | REG_LINK | A symbolic link (UNICODE) to another registry key, specifying a root key and the path to the target key |
| 7 | REG_MULTI_SZ | A multi-string value, which is an ordered list of non-empty strings, normally stored and exposed in Unicode, each one terminated by a null character, the list being normally terminated by a second null character. |
| 8 | REG_RESOURCE_LIST | A resource list (used by the Plug-n-Play hardware enumeration and configuration) |
| 9 | REG_FULL_RESOURCE_DESCRIPTOR | A resource descriptor (used by the Plug-n-Play hardware enumeration and configuration) |
| 10 | REG_RESOURCE_REQUIREMENTS_LIST | A resource requirements list (used by the Plug-n-Play hardware enumeration and configuration) |
| 11 | REG_QWORD / REG_QWORD_LITTLE_ENDIAN | A QWORD value, a 64-bit integer (either big- or little-endian, or unspecified) (introduced in Windows 2000) |
Editing
Main article: Group Policy
The registry holds important settings for Windows, for installed programs, and for each user. A wrong change can cause serious problems that are hard to fix, so usually only installer programs change it. If a person edits it by hand, Microsoft suggests making a backup first. Tools such as RegEdit.exe let users create, change, rename, and delete settings. They can even edit the registry on another computer on the same network. Sometimes editing the registry is the only way to fix certain Windows problems.
Settings can also be changed in other ways. Group policies can change registry settings on many computers or for single users. People can also work with the registry from the command line, through Windows PowerShell, or by writing programs and scripts in programming languages.
Security
Main article: Security descriptor
Each key in the Windows registry can have a security descriptor. It holds an access control list (ACL), which says which groups or individual users are allowed to access the key and which are not. There are 10 registry permissions that can be given to or taken away from a user or group.
Windows Resource Protection is a feature of Windows Vista and later versions of Windows. It stops administrators and the system from changing some important keys. This helps keep Windows safe from harmful software and accidental changes. Special settings can also stop programs with lower levels of access from changing registry keys, even if their account would normally allow it. This is called mandatory integrity control.
| Permission | Description |
|---|---|
| Query Value | The right to read the registry key value. |
| Set Value | The right to write a new value |
| Create Subkey | The right to create subkeys. |
| Enumerate Subkeys | Allow the enumeration of subkeys. |
| Notify | The right to request change notifications for registry keys or subkeys. |
| Create Link | Reserved by the operating system. |
| Delete | The right to delete a key. |
| Write DACL | The right to modify permissions of the container's DACL. |
| Write Owner | The right to modify the container's owner. |
| Read Control | The right to read the DACL. |
Over the years, different versions of Windows have offered several ways to back up and restore the registry. Some of these methods are no longer used. System Restore can back up the registry and restore it while Windows is still starting, or from the Windows Recovery Environment, which began with Windows Vista. NTBackup can back up the registry as part of the System State, and Automated System Recovery in Windows XP can also restore it. Windows 98 and Windows ME include tools that check and fix the registry. They can also run from MS-DOS.
Windows 95 came with tools to back up and restore the registry. It saved copies of the registry files each time the computer started up successfully. Windows NT 4.0 included a tool to back up and restore the whole registry. The Windows 2000 Resource Kit had extra tools for the same job, but these were not officially supported. On Windows 10 May 2019 Update (version 1903), automatic backups of the registry are turned off by default. Microsoft recommends using System Restore instead.
Policy
Windows 2000 and later versions use Group Policy to set rules for the registry. These rules can be used on one computer, or on many users and computers in a domain. Older versions of Windows, such as Windows 95, Windows 98, Windows ME, and Windows NT 4.0, used a special policy file instead. This file stopped regular users from changing some settings, such as the security level of Internet Explorer and the desktop wallpaper. It was mainly used in businesses with many computers. The business could then protect its computers from changes made by mistake.
Virtualization
Windows NT systems can send some requests for APIs that deal with INI files into a virtual file in the registry, such as HKEY_CURRENT_USER. This is done using a feature called "InifileMapping." It was added so older programs made for 16-bit versions of Windows could run on Windows NT. On Windows NT, the System folder was no longer a good place for user-specific data. Some 32-bit programs that do not follow the rules can be sent to the same place.
Windows Vista added a limited form of registry virtualization. Some programs are poorly written. They do not follow the principle of least privilege. They try to save user data to a read-only system location, such as HKEY_LOCAL_MACHINE. Windows quietly sends these programs to a better place, and the program itself does not need to change. Application virtualization works in a similar way. Low integrity processes can also use registry virtualization to help block some security exploits. The Application Compatibility Toolkit provides shims that can redirect registry operations to HKEY_CURRENT_USER. This helps programs work for users who do not have enough rights.
Disadvantages
Critics said the registry in Windows 95 was a single point of failure. If the registry was damaged, the operating system had to be installed again. Windows NT uses transaction logs to protect the registry when it is updated. Current versions of Windows use two levels of log files. These help keep the registry safe even during a power failure or other serious event. When an error cannot be fixed, Windows can still repair or re-create damaged registry entries when it starts up.
Richard WM Jones wrote libguestfs and hivex. These are tools for reading and writing the registry from other systems, including systems that are not Windows. He has raised several concerns. He says the registry works more like a file system than a database, and that it is incomplete. Its format is based on the struct layout of the original compiler from the 1990s. Windows checks the registry too little, so it can be made to hang or crash. Different versions of Windows also understand some kinds of data differently. This means a person needs to know which Windows version they are using to read and write the registry correctly.
Equivalents and alternatives
On Windows, programmers choose whether to use the registry to store program data. Microsoft lets them save data in XML files (using MSXML) or in database files (using SQL Server Compact). Programmers can also use other companies' tools or make their own way to store data.
Other systems handle settings differently. Many use separate plain-text files for daemon and application settings. These files are grouped together so they are easier to manage. On Unix-like systems, such as Linux, system-wide settings are usually kept in /etc/. These systems follow the Filesystem Hierarchy Standard. Personal settings are kept in hidden files whose names start with a period (full stop) in the user's home directory. On macOS, settings are kept in /Library/ folders, and apps often store a property list file. RISC OS uses folders for settings. This means programs can be copied into application directories instead of being installed separately. IBM AIX uses a part called Object Data Manager to store system and device settings. The GNOME desktop uses a registry-like system called dconf. The Wine compatibility layer lets Windows software run on Unix-like systems. It stores its registry in text files. The Elektra Initiative offers other ways to handle text configuration files.

Quiz time!
4 questions about Windows Registry
What kind of thing is the Windows Registry?
Keep exploring
This article is a child-friendly adaptation of the Wikipedia article on Windows Registry, available under CC BY-SA 4.0.
Images from Wikimedia Commons. Tap any image to view credits and license.