15.1 The five registry hives
Depending on your XP configuration and the programs you've installed, your Registry may have thousands of settings or tens of thousands of them. The settings are organized into five main Registry sections, called Registry hives . Figure 15-1 shows the structure of the Registry (the hives simply appear as folders), displayed in the Registry Editor.
Here what each Registry hive does:
HKEY_CLASSES_ROOT . Contains information about file types, filename extensions, and other details related to files. It tells XP how to handle different file types, and controls basic interface options like double-clicking and context menus .
HKEY_CURRENT_USER . Contains configuration information about the setup of the person currently logged into XP. It controls the desktop, as well as XP's specific appearance and behavior for that individual, including screen colors and the arrangement of the desktop. It also manages the connections to the network and to devices like digital cameras or printers.
HKEY_LOCAL_MACHINE . Contains information about the computer itself, as well as the operating system. It includes specific details about all hardware, including the keyboard, printer ports, and storage devices. It also has information about security settings, installed software, system startup, drivers, and other services, like the ability to automatically connect to wireless networks.
HKEY_USERS . Contains information about every user profile on the system.
HKEY_CURRENT_CONFIG . Contains information about the system's current hardware setup, in the same way that HKEY_CURRENT_USER contains information about whoever's logged into the system at the moment. It has details like the type of hard disk installed in your PC, for example.
Note: When you delve into the Registry, you may notice that many of the settings seem to be exact duplicates of one another; in other words, a setting in one hive is the same as a setting in another hive. In fact, frequently one group of settings is merely an alias (also called a symbolic link )or shortcutfor a group of settings in a different hive, so when you change those settings in one place, they take effect in both locations.
| || |
Figure 15-1. Here's a look at the Registry's five hives through the eyes of the Registry Editor. You navigate with the Registry Editor much like Windows Explorer: expand branches by clicking +, and collapse them by clicking -.
15.1.1 Keys and values
Each Registry hive contains keys , which are your settings (like MenuShowDelay). And each key has a value , which contains the setting option XP or you have chosen (like 400 milliseconds ).
For instance, the value for the DoubleClickSpeed key controls the amount of time between mouse clicks that must elapse before XP considers the action to be two single clicks, rather than a double-click. DoubleClickSpeed's value is 500, measured in milliseconds, although you can edit the Registry to change that number, as shown in Figure 15-2. That means that if you click your mouse twice within 500 milliseconds, XP interprets it as a double-click. If you wait longer than 500 milliseconds before your second click, XP doesn't consider it a double-click. Changing the key's value changes how XP treats those two mouse clickseither as a double-click or as two separate clicks. So if you're a slow clicker, you might want to change that value to a larger number.
Note: DoubleClickSpeed is an example of a Registry setting that you can also change using a dialog boxin this case, the Mouse Properties dialog box (choose Start Control Panel Printers and Other Hardware Mouse). When you make changes using a dialog box, XP actually makes the changes are in the Registry, which ultimately controls the setting. The dialog box is merely a convenient way to make changes to the Registry.
| || |
Figure 15-2. When editing the Registry, you highlight a key in the left panein this case, "mouse"and edit the values in the right panein this case, DoubleClickSpeed. Each value has data associated with it, which you can edit by double-clicking the value.
A key can contain one or more values. There are several types of values for Registry keys, called data types . Below are the Registry's primary data types:
REG_SZ (String value) . Made up of plain text and numbers , this data type is easy to understand and edit. It's one of the most common data types in the Registry; for instance, the value for DoubleClickSpeed is a string value (the number 500).
REG_MULTI_SZ (String array value) . This data type contains several strings of plain text and numbers, for example, Version 3.11.01.30.97 is the value for the version of your video BIOS. (A video BIOS is a built-in piece of software necessary for your graphics card and monitor to work.)
Note: The Registry Editor lets you edit string array values, but it doesn't let you create them.
REG_EXPAND_SZ (Expanded string value) . This data type contains variables that Windows uses to point to the location of files. (A variable is information that can change, according to the circumstances.) For example, to point to the location of the file for the Luna desktop theme, the expanded string value in the Registry would be %SystemRoot%\resources\Themes\Luna.theme. It's a variable data type because the location and exact filename of the theme can change.
REG_BINARY (Binary values) . Here's a data type only a PC could love. It's made up of binary data0s and 1s that your computer can understand. The Registry represents that date by long strings of letters and numbers. Figure 15-3 shows a typical example of a binary value. As a general rule, you won't edit any binary values.
| || |
Figure 15-3. Binary values, like the one shown here, are difficult to edit. Fortunately, you probably wouldn't ever have to. (No hints in this book involve editing binary values.)
That's the background info . Now you're ready to get editing.
15.1.2 The Registry Editor
You use the Registry Editor to edit existing keys and values, create new keys and values, or delete keys and values you no longer want. Sometimes the changes take effect as soon as you make them and exit the Registry Editor; other times you have to reboot for them to work. There's no rhyme or reason as to when settings take effectit varies from key to key.
To run the Registry Editor, open the Run box or a command prompt (choose Start Run and then type cmd and press Enter), then type Regedit and press Enter. The first time you run the Registry Editor, it opens with the My Computer HKEY_CURRENT_USER hive highlighted, as you can see in Figure 15-4. If you've used the Registry Editor before, it opens with the last key you edited highlighted, or the last place you were in the Registry.
Warning: Some Registry settings control vital functions on your PC, and if you adjust them, you can permanently damage your system. Don't change any settings you don't recognize or know to be safe. (All the Registry edits in this book are, of course, OK to make.)
| || |
Figure 15-4. When you use the Registry Editor for the first time, it opens to the HKEY_CURRENT_USER hive. You generally edit keys in that hive the most, because they contain your personal XP settings.
The Registry is organized hierarchically, like a hard disk, and you browse through it with the Registry Editor the same way you browse through your files using Windows Explorer. Clicking a + sign opens the next level down; clicking a - sign closes the current level or folder.
| WORKAROUND WORKSHOP |
Navigating the Registry
Each Registry key can contain subkeys, and those subkeys can contain subkeys, and so on, which are all organized in folders, much like a hard drive. This arrangement is useful visually, but navigating it using a mouse can give your clicking finger a workout. For a less taxing option, use these shortcuts:
With the cursor in a key, press the right arrow on your keyboard to reveal subkeys.
Pressing the left arrow closes a key and moves up one level in the key hierarchy.
To jump to the next subkey that begins with a specific letter, press that lett er on your keyboard.
Even with keyboard shortcuts, sometimes finding the key you want to edit in the Registry is like navigating a maze--with lots of dead ends before you reach your goal. A faster way to find the key you need is to use the Find command by pressing Ctrl+F (same as Edit Find).
184.108.40.206 Editing keys and values
Frequently, you use the Registry Editor to edit a value that already exists. To edit a key's value, first navigate to the key you want to change. When you do that, the values show up in the right-hand pane of the Registry Editor (shown back in Figure 15-2). Double-click the value you want to edit and a box appears that lets you edit the value, as shown in Figure 15-5. Click OK when you're done.
Tip: Because the Registry Editor doesn't highlight the key you're editing, it's often hard to see where you are. (An open folder icon appears next to the key, but it's easy to miss .) To see which key you're editing, look at the status bar at the bottom of the Registry Editorit should display the current key (as in Figure 15-4). If it doesn't, from the Registry Editor menu, choose View Status Bar.
| || |
Figure 15-5. Double-click a value, and the Registry Editor lets you edit it using this dialog box. You can't edit the value name from here, only the data.
To rename a key, select it, and from the Registry Editor menu choose Edit Rename. You can also right-click the key and choose Edit Rename.
220.127.116.11 Adding keys and values
Sometimes in order to customize XP or give it a new feature, you have to add a key or a value to the Registry, as opposed to editing one that already exists. In this case, you create that key or value right in the Registry Editor. For example, if you want to add a new option to the menu that pops up when you right-click a file in Windows Explorer (which lets you quickly copy files to a folder), you have to create a new key called Copy To.
To add a new key, you first have to select the appropriate parent key in the left-hand pane of the Registry Editor. A parent key is the key one level up in the Registry from the key you want to create. For example, the parent key of the Mouse key is the Control Panel. The full path is:
- My Computer HKEY_CURRENT_USER Control Panel Mouse
Once you've highlighted the appropriate parent key, choose Edit New Key. Then type the new key's name. For a quicker way, right-click the parent key, and choose Edit New Key.
A key by itself does nothing; in order for the key to control XP, you need to give it a value. It's a two-step process. First you name the value and define what type of value it is. Then you enter the actual data for the value.
To add a value to a key:
In the left-hand pane of the Registry Editor, select the key you want .
If you haven't created the key yet, do so as outlined above.
From the menu, choose Edit New and from the submenu, select the type of value you want to create .
There are five types of values you can create, as detailed in Section 15.1.1. When creating a new value, be sure you choose the proper type, as shown in Figure 15-6.
| || |
Figure 15-6. The first step in adding a new value to any key in the Registry is choosing a value type from the Edit New menu. For example, a key that controls an on/off setting would probably use a DWORD value (Section 15.1.1). The hints in this book specify which type of value to use.
Press Enter again. The same dialog box shown in Figure 15-5 appears .
Enter the data for the valueagain, exactly as the instructions indicate and press Enter. Exit the Registry. Your settings may take effect immediately, or you might have to reboot. (Each hint indicates whether rebooting is necessary.)
18.104.22.168 Deleting keys and values
Sometimes you need to delete a key or a value in the Registry. For example, if there's a feature in XP that causes a conflict, or perhaps you've created a key and later decide you don't want that feature any more, deleting is the way to go.
Open the Registry Editor and go to the key or value you need to delete (try the search and navigation tips in the box on WORKAROUND WORKSHOP Navigating the Registry). Once you find a key or value, deleting it is simple: Select it and press Delete.
15.1.3 An Important Registry Precaution
The Registry can be rather unforgiving. Once you change it, there's no Undo commandand unlike most other Windows programs, the Registry Editor doesn't ask whether you want to save your changes, giving you a chance to back out. That means that if you make a change to the Registry and later want to go back to your original settings, you have to remember the often arcane and complicated changes you made and re-edit the Registry back to the way it was.
Actually, there's an easier way to restore your previous settings when you change the Registry: Back up the Registry before you edit or change anything, so you can easily go back to your previous settings if you want. In fact, you should make copies of your Registry not only to protect against an editing escapade that goes awry, but also to ensure that you can restore your system if it crashes while you're editing the Registry.
As luck would have it, there's a great way to back up the Registryright in the Registry Editor. You can use it to back up the entire Registry, a Registry hive, or individual branches and keys.
| || |
Figure 15-7. The quickest way to back up the Registry is to use the Export Registry File screen. If you want to back up only a portion of the Registry, choose "Selected branch" at the bottom of the screen.
To back up the Registry:
Open the Registry Editor by typing Regedit in the Run box or a command prompt and pressing Enter. Then highlight the part of the Registry you want to back up .
If you want to back up the entire Registry, highlight My Computer. To back up a single hive, highlight just that hive. To back up a key or portion of the Registry and all keys underneath it, highlight that key or portion of the Registry. If you're only editing a single key or value, you can just back up a portion of the Registry. But for general safety's sake, you should back up the entire Registry every month or so.
Choose File Export .
The Export Registry File dialog box appears, as shown in Figure 15-7.
Give the file a name, choose a location and save it .
The saved file ends in a .reg extension. Give the file a descriptive name, so you recognize it if you later need to restore the Registry. You may want to include the date as well; for example, fullbackup1009.reg.
If you want to restore the Registry to its pre-edited state, run the Registry Editor, choose File Import, and then import the backup file. (You only need to use the backup if, after you edit the Registry, your computer doesn't work properly.)
Note: A .Reg file is the easiest way to back up the Registry, but it doesn't back up two sets of Registry keys: the SAM and Security keys that control password policies, user rights, and related information. However, unless you have a complex system with many accounts, these keys aren't absolutely vital. And if you're not editing these keys, backing them up isn't important, since you aren't changing them.
15.1.4 Editing the Registry with .Reg Files
If you're the cautious type and the idea of touching the Registry makes your skin itch with anxiety, there's another way you can edit the Registry that may give you more peace of mind: using .Reg files. These are regular text files you can create or edit with Notepad or another text editor and then merge into the Registry to make your changes. You can create a .Reg file from scratch, or export one from a portion of the Registry. When you use a .Reg file, you don't have to edit the Registry itself, so you're less likely to get yourself in a jam if you make a mistake.
Warning: Never use a word processor like Microsoft Word to edit .Reg files. Word processors add extra characters to the file that the Registry doesn't understand, causing big problems when the file is merged into the Registry.
The best way to create a .Reg file is to export an existing portion of the Registry, then edit that file with a text editor like Notepad. To do it, first open the Registry Editor and highlight the key or portion of the Registry you want to export, then choose File Export. Choose a name and location for the file, and make sure it ends in .reg. You can export an individual key, a branch of the Registry, a hive, or the entire Registry. (For more details on exporting from the Registry, see the backup instructions in the previous hint.)
After you export the key, you can edit it by running Notepad (or another text editor) and opening the file. Here, for example, is the exported "My Computer HKEY_CURRENT_USER Control Panel don't load" key as it looks in Notepad:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Control Panel\don't load] "ncpa.cpl"="Yes" "odbccp32.cpl"="No"
You edit a .Reg file as you would any other text file. As you can see, the first line of the .Reg file starts with Windows Registry Editor Version 5.00. Don't change this line; Windows XP uses it to confirm that the file does in fact contain Registry information. (Previous versions of Windows have a different first line. For Windows 95/98/Me and Windows NT 4, the first line reads either REGEDIT4 or Registry Editor 4.)
The names of Registry keys are surrounded by brackets, and they include the full path name to the subkey, like [HKEY_CURRENT_USER\Control Panel\don't load] in this example. There may be multiple keys and subkeys, although this example just has one key. After each key are the key values and data. Values and data are both surrounded by quotation marks, as you can see in the above example. DWORD values, however, are preceded by dword : and don't have quotation marks surrounding them. Similarly, binary values are preceded by hex : and don't have quotation surrounding them. (For more about data types, like DWORD values and binary values, see Section 15.1.1.)
Edit the value and data according to the instructions in the hint you're using and save the file, using the same name. This example adds to the Registry a new value that stops the Phone and Modem Options applet from appearing in the Control Panel. So the new .Reg file looks like this (the new information appears on the last line):
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Control Panel\don't load] "ncpa.cpl"="Yes" "odbccp32.cpl"="No" "telephon.cpl"="No"
When you've made your changes, import the .Reg file back into the Registry by opening the Registry Editor and choosing File Import, then browsing to the edited file and opening it. An even easier way to import it is to find the file using Windows Explorer and double-click it. When you do so, XP asks whether you want to import the file. Answer yes, and XP imports it and makes the change to the Registry. This point can be very confusing: You may at first think that double-clicking a .Reg file opens it for editing, but it doesn'tit merges it into the Registry.
15.1.5 Protecting the Registry
As mentioned in the previous tip, when you double-click a .Reg file, XP merges it directly into the Registry instead of simply opening it up for editing as you might expect. Accidentally double-clicking a .Reg file can cause serious problems: Instead of opening a file, you inadvertently make changes to the Registry.
To avoid this fiasco, you can change the action XP takes when you double-click a .Reg file, so XP opens the file for editing in Notepad rather than merging it into the Registry. Here's how:
In Windows Explorer, choose Tools Folder Options File Types .
This opens the File Types dialog box.
Highlight the REG entry and click Advanced .
The Edit File Type dialog box opens, where you can change the action XP takes when you double-click a .Reg file.
Highlight the Edit entry and click the Edit button .
A dialog box appears. The Action box should have the word "edit" in it, as in Figure 15-8.
| || |
Figure 15-8. Using this screen, you can change the action XP performs when you double-click a .Reg filein this case, opening the file in Notepad for editing rather than immediately making a Registry change.
In the box that says "Application used to perform action," enter C:\WINDOWS\system32\NOTEPAD.EXE %1 and click OK, and OK again in every dialog box that appears .
This path tells XP to use Notepad to open .Reg files when you double-click them. If you want to use another text editor, use its full path and name instead of the path to Notepad. Make sure you add %1 after the application's name, because that tells the text editor to open the file you double-click.
15.1.6 Creating a Registry Favorites List
Navigating through the many levels of the Registry can be time-consuming and frustrating, especially when you're trying to find a key you know you edited before. You can't leave a trail of electronic breadcrumbs to find your way back, but you can add keys you use frequently to the Registry Editor's Favorites list. That way, you can quickly return to keys you've used before.
Adding a key to the list is simple: just highlight it and choose Favorites Add to Favorites. You can do this at any level of the Registry, not just with individual keys. So, for example, if you often edit keys found within My Computer HKEY_CURRENT_USER HARDWARE, you can put that location on your Favorites list. To use the Favorites list, click the Favorites menu; a menu opens with your Favorites listed at the bottom (Figure 15-9).
| || |
Figure 15-9. Once you add keys and locations to your Registry Favorites, they're available whenever you click the Favorites menu.
Note: There's one problem with Favorites: it uses the name of the current key, but not its full path. So, for example, if you add the key "My Computer HKEY_LOCAL_MACHINE SOFTWARE Netscape Netscape 6 6.2.1 (en)" to your Favorites, it shows up as "6.2.1 (en)" on the Favorites menu, which isn't particularly descriptive when you're scanning the menu six months later.As you're adding a favorite, edit the name of the key or branch to something you're more likely to remember. It's easy: when you click Add To Favorites, an Add To Favorites dialog box appears. To rename a Favorite, in the Favorite name box that appears, type a more descriptive name you're likely to recognize.
15.1.7 Printing the Registry
Looking through the Registry with the Registry Editor can be maddeningly confusing. There are literally thousands of entries, all nested within one another, and many are very similar. It's like being stuck in the most complicated maze you can imagine. In some cases, you may find it easier to look through the Registry on paper. With the Registry Editor, you can print out a single key, a branch of the Registry, a whole hive, or the entire Registry.
Printing the whole Registry, or even an entire hive, takes a substantial amount of time and paper, so start by printing small sections, then go back and print more if you need other information.
To print any portion of the Registry, navigate to the key, subkey, or section you want to print, and then choose File Print, or press Ctrl+P. That prints the current key, plus every subkey and value beneath it.
| ADD-IN ALERT |
Other Registry Tools
The Registry Editor is a perfectly serviceable tool, as far as it goes. But if you're planning to do a lot of tinkering with the Registry, it doesn't go far enough. For instance, it doesn't offer a way to clean out old, unused Registry entries, or include easy-to-use editing tools. So if you want more bells and whistles, try the following software downloads:
Registry First Aid . When you install and uninstall software, and as your system ages, the Registry begins to fill up with old or unnecessary Registry entries that clog up your system. Registry First Aid finds these obsolete entries and lets you delete them. ($21 shareware; http://www.rosecitysoftware.com.)
Registry Commander . This free utility gives you a host of features the Windows Registry Editor left out, such as a history list that lets you jump to recently edited keys, the ability to bookmark keys, a way to copy and paste entire keys, and advanced searches. Get it at http://www.aezay.dk.
Resplendent Registrar. This exceedingly powerful Registry editor includes even more tools, such as a search-and-replace feature, a Registry defragmenter to reclaim wasted disk space, an activity monitor that tracks all Registry activity, and a tool for comparing the contents of two Registry keys--plus lots of other helpful features. ($21 shareware: http://www.resplendance.com).
Registry Mechanic . This program analyzes your Registry and fixes any problems it finds. It also backs up the Registry before making any changes. That way, if a particular fix just creates more problems, you can easily restore your Registry to the state it was in before Registry Mechanic got involved. ($19.95 shareware; http://www.winguides.com).