[Previous] [Contents] [Next]


The Registry


As explained in Lesson 1, the Registry is a common database composed of two binary files: SYSTEM.DAT and USER.DAT, which are located in the Windows directory. Inside the Registry is information on all the hardware in the computer, network information, user preferences, and file types, as well as virtually anything else you might run into within Windows 95.

NOTE
The Registry is intended to replace CONFIG.SYS, AUTOEXEC.BAT, and every .INI file. However, Windows 95 still reads all .INI files at boot up for backward compatibility with Win 3.x programs that need them.

Why the Change in Windows 95?

Windows 3.1x supported two kinds of .INI files: system initialization files and private initialization files. System initialization files controlled the Windows environment and included SYSTEM.INI and WIN.INI. Private initialization files included CONTROL.INI, PROGMAN.INI, WINFILE.INI, and PROTOCOL.INI, as well as any application .INI files. Initialization files created a bridge between the application and the Windows operating environment.

In addition to .INI files, Windows 3.1 used a host of other text files to manage operations. The files included AUTOEXEC.BAT and CONFIG.SYS. It was conceivable for a user to have more than 150 files responsible for the operation of the computer and the Windows environment.

During the development of Windows 3.11, it became apparent that a move away from the .INI files was needed. A new file type was introduced into the programming environment. The file was called REG.DAT and was the precursor to the Windows 95 Registry. REG.DAT included information used for drag-and-drop operations, object linking and embedding (OLE), and establishing associations between data files and their programs.

The binary file REG.DAT was bundled with its editor, REGEDIT.EXE. While this began the process of centralizing computer operations, REG.DAT came with some serious size limitations. It could not exceed 64 KB, which is the same limit established for the .INI files in Windows 3.11.

Accessing the Registry

The recommended way to access the Registry is through the Control Panel. It lets a user modify settings with an easy to use interface that never even mentioned the word Registry. In Windows 3.x, most such changes required modifying the SYSTEM.INI file.

TIP
Everything necessary to configure the system so that it will work can be handled from the Windows 95 Control Panel. The three areas where Windows 95 preferences/settings can be viewed and configured are the Control Panel, the System Monitor, and the Registry.

Directly changing an entry (to be done only by a knowledgeable user) is accomplished with the Registry Editor, REGEDIT.EXE. To open it, type REGEDIT at a command prompt. This can be obtained by typing the command in the dialog box that appears when you choose Run from the Start menu. The Registry itself is stored in binary format, so you can't open, view, or edit the contents directly.

Microsoft tried to make the Registry as inaccessible as possible. The fact that the Registry is the central repository creates its principal weakness-once it has been corrupted, it's hard to recover settings if they haven't been backed up.

The Registry is stored in three locations:

  • SYSTEM.DAT: Stores most of the data, including the majority of hardware and software configurations.
  • USER.DAT: Stores data about a particular user.
  • The Virtual Registry: Consists of a host of files that are created by Windows 95 when the system is started up. They are stored in RAM. These settings relate to many of the performance-monitoring tools such as PVIEW.EXE.

Components of the Registry

The Windows 95 Registry consists of six root keys, each of which reflects a different aspect of the configuration. Each key or branch of the Registry groups information that logically belongs together. All top-level keys are called root keys and defined and named by Windows 95. These cannot be changed. Root keys are named HKEY_XXX and can be followed by several subkeys. All other keys in the Registry are subkeys of these six primary keys. Subkeys can be added, deleted, or renamed. The six root keys are shown in Figure 16.5 and are explored in the following sections.

Figure 16.5 Registry root keys

HKEY_CLASSES_ROOT

This section of the Registry defines the standard-class objects used by Windows 95. Do not make any changes to this section. This is a link to the HKEY_LOCAL_MACHINE\SOFTWARE\Classes, which simply provides compatibility with the Windows 3.1 registration database. This compatibility is important if you want to run Windows 3.1 16-bit applications in Windows 95.

HKEY_CURRENT_USER

This section defines the current user settings-it's not important for repairing computers. Personalized information like fonts, some icons, and colors can be changed here. This is a link to the HKEY_USERS key. This key provides Windows 95 compatibility to applications using the Windows NT Registry structure.

HKEY_LOCAL_MACHINE

This portion of the Registry contains all the data for the system's non-user-specific configurations (including every device in the computer). This is the largest key in the Registry and the place you will perform the bulk of your system edits to optimize Windows 95 performance. Information stored here includes hardware configuration, peripheral devices, installed software, OLE compatibility, software configuration, and Windows 95 configuration. The data stored in HKEY_LOCAL_MACHINE is stored in the SYSTEM.DAT file.

HKEY_USERS

This section of the Registry is where Windows 95 keeps track of the different user settings. If your computer is not configured for multiple users, you will have a single subkey named DEFAULT. If your computer has been configured for multiple users, two profiles are created when you log on: HKEY_USERS\.DEFAULT and HKEY_USERS\user name\user.dat. If it's a two-user system, the other user's settings are held in memory. This makes it impossible to alter user settings without logging on under their name and password.

HKEY_CURRENT_CONFIG

This key handles Plug and Play and contains information about the current configuration of a multiple-hardware-configured computer. This key works in conjunction with HKEY_LOCAL_MACHINE\Config\xxxx, where xxxx is the subkey that represents the numeric value of the current hardware configuration.

HKEY_DYN_DATA

This is Registry data that is stored in RAM to speed up system configuration. A snapshot of all hardware in use is stored here. It is updated on boot up and when any changes are made in the system configuration file. This portion of the Registry is dynamic. It's where virtual device drivers are installed, where Plug and Play hardware information is maintained, and where performance statistics are calculated. Because this information is accessed and changed constantly, this portion of the Registry is never written to the hard disk. It resides in the computer's RAM.

Editing the Registry

CAUTION
Editing the Registry directly can cause serious problems if it is not done correctly. Windows 95 provides the Control Panel and Properties sheets for editing the Registry. Microsoft recommends these methods. Microsoft does not support direct editing of the Registry.

If you feel you must edit the Registry, then back up first (see the end of this section for details on backing up the Registry). The tool used to edit the Registry is REGEDIT.EXE. (See Figure 16.6.) This program is not included in any of the menus and will not be found on the desktop. You must either activate REGEDIT.EXE through Windows Explorer or start the program from the command line.

Click to view at full size.

Figure 16.6 REGEDIT

The following table provides an overview of the commands in the REGEDIT.

Menu Commands
Registry Import Registry File: Allows you to take a Registry file that you've created or modified and import it into the current Registry. Importing a Registry file is often the best way to rescue a corrupted Registry or to replace the current damaged Registry with a known good backup.

Export Registry File: Allows you to export the Registry file to a floppy disk or network location. Exporting a Registry is one of the best ways to back up your Windows 95 system.

Connect Network Registry: Allows you to connect to a user on your network and, if you have the proper authority, modify that user's Registry. This is a very powerful feature, not necessarily one that a majority of users should have access to.

Disconnect Network Registry: Releases the connection to a network user's Registry.

Print: Allows you to print either the entire Registry, or just one of the keys or branches in the Registry.

Edit New: Allows you to create keys and assign values.

Delete: This command allows you to delete a key, key value, or value name.

Rename: This command lets you rename either a key or value name.

Find: Allows you to find a particular string or key value name.

Find Next: Finds the next value that was defined in the Find command.

View Status Bar: Either hides or shows the status bar at the bottom of the screen.

Split: This command lets you move the split bar (vertical separation) between the Key window (on the left) and the Value window (on the right).

Refresh: This command refreshes the REGEDIT screen.

NOTE
The Edit command doesn't include the typical Copy, Cut, and Paste options. If you need to copy and paste in REGEDIT, you will need to use the Windows keyboard commands. Press CTRL+C for Copy, and CTRL+V for Paste. These two commands are a necessity if you do a lot of searching and replacing in the Registry.

REGEDIT's Dual Purpose

REGEDIT is more than a Windows utility program. It can be used from inside real-mode MS-DOS. This is particularly important if you have a seriously corrupted Registry file and Windows won't start. During installation, Windows 95 puts a copy of REGEDIT.EXE on the startup disk. When running REGEDIT in real mode, it doesn't have an interface-it uses a command-line format to carry out instructions. The following table lists the most common REGEDIT switches.

Switch Function
/? Displays the REGEDIT command-line syntax.
/L:system Provides the location and filename of SYSTEM.DAT.
/R:user Provides the location and filename of USER.DAT.
/E filename <regpath> Creates a Registry (.REG) file.
/C filename Replaces the entire Registry with the contents of your .REG.

To use REGEDIT in real mode, you'll need to tell it where your SYSTEM.DAT and USER.DAT files are located, if they are in a directory other than Windows.

Here is the syntax needed to replace an existing, corrupt Registry with the contents of the .REG file you created. Remember, this command is typed in full at the MS-DOS prompt:


Using REGEDIT to Modify the Registry

Before modifying the Registry, make sure it is backed up sufficiently. When you edit the Registry, consider using the Control Panel and the applications contained inside of it to make Registry edits. The Control Panel is the wizard for updating specific parts of the Registry. A corrupted Registry is not something you can easily recover from.

Edits to the Registry can be made using either the menu or the right mouse button. Adding keys can be accomplished by simply right-clicking the key you want to add to and entering your information. Windows 95 has two restrictions you need to be aware of when adding keys:

  • You cannot add a top-level key. Windows 95 creates those.
  • Within a parent key, each subkey name must be unique. You can use the same subkey name in different parent keys.

Modifying the value section of the Value entry can be accomplished with a double-click on the value in the Value window. After you double-click the value, you will see one of three different dialog boxes.

Windows 95 uses multiple registers for multiuser operations, and it can be difficult to know exactly where pieces of information are stored. The System Policy Editor allows administrators to locate where information is stored.

Backing Up the Registry

Backing up the Windows 95 Registry is one of the most important parts of maintaining a personal computer. Because the Registry is so undocumented, the only way to recover from Registry errors is by restoring the Registry data. A corrupt Registry can disable a few components of a particular piece of software, or it can prevent Windows from booting. Microsoft has provided a number of different tools to back up the Registry. No single tool offers the total solution, but if used in combination they can provide a very effective backup strategy.

Every time you add a piece of software, adjust a system component, or make a new connection, the Registry is changed. The Registry is extremely dynamic and needs to be backed up any time it is changed.

There are three primary Registry backup tools available in Windows 95:

  • Microsoft Configuration Backup (CFGBACK.EXE)
  • Emergency Recovery Utility (ERU.EXE)
  • .REG files

Microsoft Configuration Backup (CFGBACK.EXE)

CFGBACK.EXE (Microsoft Configuration Backup) is a proprietary program that creates backups that can be restored only from inside this program. CFGBACK allows you to create up to nine iterations, or different backup files, of a Registry. Once the program is installed, start it and choose the option you want to execute: Backup or Restore. One nice feature of CFGBACK is that it allows you to write a description of why the backup was run (for instance: "Before MSOffice installation" or "After MSOffice installation"). See Figure 16.7.

Figure 16.7 CFGBACK.EXE

Configuration Backup is available in two places: on the Windows 95 CD in the folder \Other\Misc\CFGBACK, or on the CD included with the Windows 95 Resource Kit. Either way, you need to load the file from the CD to your Windows 95 system before you can use it.

The limitations of CFGBACK.EXE include the following:

  • If a Windows 95 system has multiuser settings, CFGBACK.EXE will not back up the separate user settings.
  • CFGBACK.EXE will not help if Windows 95 itself cannot start. CFGBACK.EXE runs inside Windows 95, not in MS-DOS real mode. One of the best ways to bring your system back from a Windows boot-up failure is to use the .REG files created using REGEDIT.

Emergency Recovery Utility

The Emergency Recovery Utility (ERU.EXE) is available on the Windows 95 CD in the folder \Other\Misc\Eru. The ERU.EXE program backs up all critical system files, including AUTOEXEC.BAT, COMMAND.COM, CONFIG.SYS, IO.SYS, MSDOS.SYS, PROTOCOL.INI, SYSTEM.DAT, SYSTEM.INI, USER.DAT, and WIN.INI.

ERU.EXE also creates an MS-DOS real-mode file, called ERD.EXE, that you can use to restore from MS-DOS if the Windows system fails to start up.

The limitations of ERU.EXE include the following:

  • When backing up to a floppy disk, ERU.EXE determines the amount of space available to perform the backup. If the disk doesn't contain enough space, it will simply not back up one of the components. Unlike the old MS-DOS BACKUP command, which could back up over multiple diskettes, ERU.EXE can back up only to a single floppy disk.
  • On a multiuser system, ERU.EXE fails to create a backup of Registry settings related to the current user.
  • If ERU.EXE can't find a file it is trying to back up, it will hang without giving you an error message. You are left on your own to try to figure out the problem. If it hangs, however, you can usually assume that you're missing one of the files that it's trying to back up.

Using .REG Files

One of the features of REGEDIT is its ability to export Registry information. By creating a .REG file that backs up your entire system, you can easily restore a Registry. To rescue a Registry, you use either REGEDIT in Windows or the real-mode REGEDIT found on your Rescue disk.

TIP
If you don't know where your Windows 95 Rescue disk is, you can re-create it by doing the following: Go to the Control Panel and click the Add/Remove programs applet. Inside the applet, click the Startup Disk tab and follow the instructions.

Additional Restore Techniques

Windows 95 comes with at least two other techniques you can use to restore your system. Often, these techniques are the quickest ones available to you, and offer the easiest solution.

The first technique is to let Windows try to restore your Registry. Give that a try if, during boot, you see the message shown in Figure 16.8.

Click to view at full size.

Figure 16.8 Registry problem

NOTE
Remember what the message says: "Restoring the Registry will replace the faulty Registry with a known good backup copy. However, this backup copy may not contain all of the information recently added to your system."

The second technique is to restore the Registry in MS-DOS mode by replacing the SYSTEM.DAT and USER.DAT files. Follow these steps:

  1. Click the Start Button and select Shut Down.
  2. In the Shut Down dialog box, select Restart The Computer In MS-DOS Mode.
  3. After you're in MS-DOS mode, make sure you're in the Windows directory. You can change directories (folders) by typing:

  4. Next type each of these commands as they appear in this order:

NOTE
These commands will change the Registry files from hidden read-only to non-hidden read/write files and then replace the original Registry files with the backup files.
  1. Restart your computer.

Registry Restored But Windows Problems Remain

Not all Windows problems are attributable to a corrupt or bad Registry. Some problems relate to erroneous entries in either the SYSTEM.INI or WIN.INI files. Not everything critical to your system is stored in the Registry.

When backing up a Registry, you should also back up SYSTEM.INI and WIN.INI. If you get one of the following two error messages, it is possible that the problem lies elsewhere besides the Registry or the .INI files:


It could be that you have a missing or bad MSDOS.SYS file. If you receive one of those error messages, find your Startup disk and copy the MSDOS.SYS file from the disk to your Windows directory.

Last Resort Before Reloading Windows 95

When it was originally set up on your computer, Windows created another SYSTEM.DAT file during installation called SYSTEM.1ST. If you want, you can reload SYSTEM.1ST using the following real-mode commands:


If none of these solutions work, you'll need to reload Windows.

Windows Registry

The Windows Registry is very complex, and we have touched only on some of its more important aspects. To learn more about the Registry and how to edit it, we suggest you add the following text to your technical library: Inside the Registry for Microsoft Windows 95, Gunter Born, Microsoft Press, 1997.


[Previous] [Contents] [Next]