Site hosted by Angelfire.com: Build your free website today!
Chapter 38: Registering Programs and File Types

PreviousChapterContentsGlossaryNext

Editing the Registry

The Windows Registry contains a great deal of information beyond the file associations discussed in the previous section. For the most part, you won't need to do any editing yourself, but occasionally, a bug fix or parameter change requires a change to the Registry, so you need to be prepared to do a little editing now and then. If you're interested in how Windows works, you can also spend as much time as you want nosing around the Registry with the Registry Editor program.

warning Never make changes to the Registry without first making a backup! Better yet, include the Registry in your daily backups.

Restoring the Registry

If the Registry is damaged, you can restore it from a backup. Follow these steps:

  1. Save your files and close all your programs.
  2. Choose Start | Turn Off Computer | Restart. Windows shuts down and restarts.
  3. When you see the message Please Select The Operating System To Start, press F8. Windows displays a list of options.
  4. Press the UP-ARROW or DOWN-ARROW until you highlight the Last Known Good Configuration option, and press ENTER. (If the arrow keys don't work, press NUM LOCK to enable them.)
  5. Choose the operating system (either Windows XP Professional or Windows XP Home Edition). Windows then restores your most recently backed up values for the HKEY_LOCAL_MACHINE\System\CurrentControlSet hive in the Registry, and restarts Windows.

If the Registry entries for an application get damaged, consider uninstalling and reinstalling the program. If restoring a backup of the Registry still doesn't fix your problem, you may have to back up your data, reformat the disk (or partition) on which Windows is installed, and reinstall Windows and all your programs.

note System Restore can also restore a previous version of the Registry.

Running Registry Editor

Registry Editor (Regedit for short) lets you edit anything in the Registry. To run Registry Editor, select Start | Run, type regedit, and press ENTER. This chapter describes Registry Editor version 5.

caution Registry Editor has almost no built-in checks or validation, so be very sure that you make any changes correctly. Incorrect Registry entries can lead to anything from occasional flaky behavior to complete system failure. We suggest that you export the keys that you plan to edit before making any changes, so that you can reimport them if the changes cause problems.

Finding Registry Entries

Registry Editor has a two-part window, shown in Figure 38-1, much like Windows Explorer. Each key is shown as a folder in the left pane of the Registry Editor window. When you select a key in the left pane, the name and data of each of its values appear in the right pane. You can expand and contract parts of the name tree by clicking the + and - icons in the key area. Select any key to see the names and data of the values, if any, associated with that key.
[figure]
Figure 38-1: Looking at the Registry

If you know the name of the key you want, you can navigate through the key names similar to the way you navigate through files in Windows Explorer.

If you don't know the name of the key, you can search for it by choosing Edit | Find (or pressing CTRL-F). You can search for any combination of keys, value names, and value data. For example, if you mistyped your name at the time you set up Windows and want to correct it, search for the mistyped name as value data. Press F3 to step from one match to the next.

tip As you edit Registry entries, Registry Editor makes the changes right away--there's no Save, Cancel, or Undo command. You can edit the Registry and leave the Registry Editor window open while you check whether your changes produce the desired effect. Some programs aren't affected by Registry changes until they are restarted; others reflect the changes immediately.

When you run Registry Editor again, it displays the key that you were looking at when you last exited the program, so it's easy to continue making changes to the same key.

Adding and Changing Registry Entries

You can add, edit, and delete Registry entries (but be sure you back them up first):


[image]

You can't change the type of a value, so you have to enter a text string, a numeric value, or a string of hexadecimal digits, depending on the type of the data.

tip If you're not absolutely sure about deleting a key, rename it. Add an underscore or number to the end, so that the Registry doesn't recognize it, but you will if you need to change it back later.

You can also rename and delete keys and values by using the Edit menu.

tip If you want to remember the name of a Registry key--or tell a friend about it--you can copy it to the Clipboard. Select the key whose complete name you want, and choose Edit / Copy Key Name from the menu bar.

Editing the Registry as a Text File

Another way to edit the Registry is to export all or part of the Registry to a text file, edit the text file, and then import the changed values back into the Registry. You can export and import the entire Registry or one "branch" of the Registry's tree of keys. Registry Editor stores the exported Registry entries in a registration file with the extension .reg.

A registration file consists of a series of lines that look like this:

[HKEY_CLASSES_ROOT\.bfc\ShellNew\Config]
"NoExtension"="Temp"

The first line is the name of the key (enclosed in square brackets) and the lines that follow are the values in the key, in the format "name"="value".

note Windows XP (like Windows NT and2000) exports the Registry using Unicode rather than plain text. You can't export keys from the Windows XP Registry and import them into a Windows Me/9x Registry.

Follow these steps to edit the Registry by using a text editor:

  1. Select a hive or key in the left pane, choosing one that contains all the keys that you want to edit. To export the entire Registry, select the My Computer item at the root of the Registry tree.
  2. Choose File | Export to write the text file. Registry Editor asks you for the folder and filename to use for the registration file. Then it writes the data into the new file, which may take a few minutes.
  3. Edit the registration file in any text editor. (Notepad works fine.) Right-click the .reg file in Windows Explorer and choose Edit from the shortcut menu that appears. Notepad runs (or another text editor, if you choose it). Make as few changes as possible to the file and save the file.
  4. In Registry Editor, choose File | Import to read the edited file back into the Registry. The keys and values in the imported file replace the corresponding keys and values in the Registry. Note that if you delete a key or value in the text file, importing the file doesn't delete the key or value in the Registry.

tip The Registry is quite large--an exported version of the whole thing can be 30MB or more. If you do plan to edit it, just export the branch you plan to work on.

Running Programs on Startup

You can tell Windows to start a program automatically when Windows starts up by including a shortcut to it in the Startup folder of your Start Menu. However, there are two other ways to run a program automatically when Windows starts: lines in the Win.ini file and keys in the Registry.

The Win.ini file (which is stored in C:\Windows, assuming that Windows is installed on C:), can include lines like this:

run=program
load=program

Replace program with the pathname of the file that contains the program. To stop a program from running, remove this line from the Win.ini file, or add a semicolon at the beginning of the line.

Two places in the Registry can contain entries that run programs at Windows startup. Look in these two keys:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Current Version
HKEY_CURRENT_USER\Software\Microsoft\Windows\Current Version

These keys can contain keys named Run, RunOnce, or RunOnceEx, which contain values that start programs when Windows starts. To stop the program from running, remove or rename the key.

PreviousChapterContentsGlossaryNext