A Guide to the Windows Registry
Monday, June 4th, 2007The Windows registry has been around since Windows 3.11. Its main purpose was to replace the many text configuration files for programs that were littered about the file system and separate the user configuration from the system configuration. In this way each user has their own configuration which would have been much harder to implement with text files stored wherever the application happened to think they should go. Additionally, it allows much greater flexibility for remote administration, is much easier to backup and monitor and is a lot faster than parsing text files.
Of course like many good ideas the registry has mutated into a maze of program settings and confusing keys and values, particularly those that deal with the Windows operating system. While most of the inherent stability problems that plagued earlier versions of Windows have been resolved, the registry is still easily corrupted by third-party programs (whether by accident or malicious intent) and fixing it by hand is usually out of the question for anyone but operating system experts. There are also a few drawbacks to the registry system:
- A single point of failure – if the registry file itself is corrupted the operating system may not boot at all. Since it is the single place for configuration storage, the registry is being written to constantly.
- The registry does not contain any documentation (although some keys and values are documented by Microsoft and various Internet sites), so it is difficult and dangerous to edit by hand.
- It is very difficult to backup parts of the registry. Usually programs that clean the registry will back up the changes they make, but in general you can’t restore registry changes for a particular program without restoring the entire registry.
- Applications leave registry entries behind which can cause slow performance and system crashes. There is a particular section of the registry where orphaned entries cause problems (and we’ll get to that later).
- It is very difficult to transfer application settings from one computer to another. Microsoft has provided a tool to transfer all settings (File and Settings Transfer Wizard) or settings for individual Microsoft programs, but it can be hit or miss if the second computer does not have all the programs that the first computer has.
Registry Structure
The registry is divided into 5 “hives” which contain all the registry keys and values. A key is like a folder that contains values. The five hives are:
- HKEY_CLASSES_ROOT (HKCR) – stores information about applications that register themselves with Windows. This is the hive where most performance-related issues can be traced to, as items are registered to programs that no longer exist. This hive is actually merged from keys in the next two hives.
- HKEY_CURRENT_USER (HKCU) – stores user-specific settings and changes with each user that logs in. Each user folder in Documents and Settings contains a file called NTUser.dat where these user-specific settings are stored.
- HKEY_LOCAL_MACHINE (HKLM) – stores machine settings that do not change when different users log on. This hive is vital for the proper functioning of the operating system.
- HKEY_USERS (HKU) – stores all user-specific settings (i.e, HKEY_CURRENT_USER for every user on the computer). HKEY_CURRENT_USER is loaded from this hive.
- HKEY_CURRENT_CONFIG (HKCC) – stores data gathered during boot and is regenerated every time the computer restarts.
The HKCR hive is where many performance issues and errors stem from. This hive contains information related to files opened with Windows Explorer, mainly, which program or part of a program should open what file. While simple in concept, there are thousands of keys under this hive and it uses a lot of CLSIDs, or Class IDs, instead of program names. Programs like RegCure can look up the CLSIDs and determine if the programs they reference still exist. Cleaning out entries for non-existent programs fixes a lot of errors regarding file types and speeds up performance.
Common Registry-Related Problems
There are several other registry-related problems caused by programs not installing or uninstalling correctly which can cause errors and impact performance:
- The uninstaller does not clean out the registry properly and the software is still listed under Add/Remove Programs in the Control Panel
- Programs may install different versions of the same DLL which other programs are not compatible with
- The registry may have programs loading at startup that no longer exist
- Application paths in the registry may no longer exist
It is likely that if you have installed and uninstalled a lot of software that your system has some of these problems and could benefit from a registry cleaning.