Thursday, April 16, 2009

Make a friendship with Windows Registry

If you plan on tweaking any version of Windows, you're going to have to get friendly with the Windows Registry, a database of information that defines how your PC works, including every part of Windows and its applications and interface. Editing the Registry is often the best way to tweak Windows. In fact, it's the only way to make certain changes.

Even if you've never edited the Registry directly before, you've changed it without realizing it. Whenever you change just about any setting in Windows via a menu or some other method, a Registry change is made behind the scenes, putting that new setting into effect. The menus and dialog boxes you see in Windows are often little more than a visual front end to the Registry.

But knowing how to find your way around the Registry gives you access to many more controls than Windows' menus and dialog boxes provide. To edit the Registry directly, use Windows' built-in Registry Editor, shown below.

At first glance, the Registry is a maze of apparently incomprehensible settings, overwhelming in their complexity. In fact, though, there's some method to the madness. In this article, I'll explain how the Registry works, give you an overview of its organization and offer detailed instructions on how to edit it.

NOTE:I am assuming that any Registry edits you make will be on your own computer. Always check with your IT department before altering a company-owned machine.

Careful!

Editing the Windows Registry is easy -- perhaps too easy. There is no Save button in the Registry. When you modify a value, it changes right then and there. There is also no Undo button. Once you make the change, it's done. If you're not careful, you could do serious harm to your computer setup, your applications and the way Windows works.

So before you touch the Registry, use System Restore to create a restore point so that you can revert to the previous version of the Registry if something goes awry. It's also a good idea, once you begin editing the Registry, to write down the current state of any key or value you plan to edit before you make any changes.

Creating a restore point

To create a restore point in Windows Vista, choose Control Panel --> System and Maintenance --> Restore files from backup --> Create a restore point or change settings.

In XP, choose Start --> Help and Support --> Performance and Maintenance --> Using System Restore to undo changes --> Run the System Restore Wizard --> Create a restore point and answer the wizard's questions.

Reverting to a restore point

To revert to a system restore point in Vista, select Control Panel --> System and Maintenance --> Restore files from backup --> Repair Windows Using System Restore and follow the directions for reverting to a restore point.

In XP, follow the same steps you would to create a restore point (above). When you get to the System Restore Wizard, choose Restore my computer to an earlier time and answer the wizard's questions.

Finding your way around the Registry

Before we begin editing the Registry Editor, we'll take a look at the overall structure of the Registry and its various components. The first thing you need to know is that the Registry has many thousands of settings, organized into five main sections, called Registry hives. Each hive has a different purpose.

Following are the five hives and what each does:

HKEY_CLASSES_ROOT: This hive tells Windows how to handle every file type and controls basic user interface options.

HKEY_CURRENT_USER: This hive contains configuration information about the system setup of the user that is currently logged into Windows. It controls the desktop, as well as Windows' appearance and behavior. It also manages connections to networks and devices such as printers; personal preferences such as screen colors; and the user's security rights.

HKEY_LOCAL_MACHINE: This hive contains information about the computer itself -- details about the hardware, including keyboard, printer ports, storage ... in fact, the entire hardware setup. In addition, it has information about global security, installed software, system start-up and drivers.

HKEY_USERS: This hive contains information about every user profile on the system.

HKEY_CURRENT_CONFIG: This hive contains information about the current hardware configuration of the system, in the same way HKEY_CURRENT_USER contains information about the current user of the system.

Understanding keys and values
Underneath each hive are keys, which can in turn contain subkeys, and those subkeys can contain subkeys, and so on, organized in directory fashion, much like a hard drive.

Keys and subkeys contain one or more values, each of which controls a particular setting in Windows. Here are the six primary types of Registry values:

String value (REG_SZ): This kind of value is easy to understand and edit because it is made up of plain text and numbers. It is one of the most common types in the Registry, and the type you're likely to edit most frequently.

For example, this value

HKEY_CURRENT_USER\Control Panel\Mouse
\DoubleClickSpeed

determines the maximum number of milliseconds that can elapse between two mouse clicks for Windows to consider them a double-click (for the user currently logged into Windows).

Binary value (REG_BINARY): This value is made up of binary data: 0s and 1s. As a general rule, you won't edit binary values.

DWORD (32-bit) value (REG_DWORD):
This value is represented as a number. Sometimes the value acts as a toggle -- 0 turns on the key and 1 turns off the key -- though other numbers may be used instead.

QWORD (64-bit) value (REG_QWORD):
This is like a DWORD value, except that it can hold larger values.

Multistring value (REG_MULTI_SZ): This value contains several strings of plain text and numbers. The Registry Editor will let you edit these values, but it won't let you create them.

Expandable string value (REG_EXPAND_SZ): This value contains the location of files and tells Windows where to find them.

Editing the Registry

With all that as a background, you're ready to get down and dirty and start editing the Registry. Edit the Registry using the Registry Editor. To launch it, select Start --> Run (on XP) or Start --> Start Search (on Vista), type regedit and press Enter (you can also type regedit at the command prompt). In Vista, you'll have to click through a UAC prompt after you press Enter.

If this is the first time you've run the Registry Editor, it will open with the HKEY_CURRENT_USER hive highlighted, as shown below. If you've previously used the Registry Editor, it will highlight the last key you edited or the last place you were in the Registry.

Browse through the Registry with the Registry Editor in the same way you browse through a hard disk using Windows Explorer. Clicking a + sign (in XP) or a light triangle (in Vista) opens a key to reveal the next level down the hierarchy. Clicking a - sign (in XP) or a dark triangle (in Vista) closes the key.

You can also use shortcut keys to navigate. Pressing the right arrow key on your keyboard opens a Registry key to reveal subkeys; pressing the left arrow key closes a key and moves one level up in the key hierarchy. To jump to the next subkey that begins with a specific letter, press that letter on the keyboard.

If you're looking for a particular key, an even faster way to navigate is to use the Find command from the Edit menu. (You can also use the Find command by pressing Ctrl-F.) To find successive keys with the same value, press the F3 key.

You use the Registry Editor to edit existing keys and values, create new keys and values, or delete keys and values. Sometimes the changes take effect as soon as you make the change and exit the Registry Editor; other times, you'll have to log off and on or reboot for them to take effect.

Editing existing keys and values
To edit a value, double-click it in the right pane of the Registry Editor. A box appears that lets you edit the value. Make the change in the box and exit the Registry.

Let's try it. We'll change the click speed of your mouse by editing

HKEY_CURRENT_USER\Control Panel\Mouse\DoubleClickSpeed

As mentioned previously, DoubleClickSpeed determines the maximum amount of time that can elapse between two mouse clicks for Windows to consider them a double-click (for the user currently logged into Windows). To change the default amount of time, edit this value. In this case, the default is 500, measured in milliseconds.

To edit DoubleClickSpeed, launch the Registry Editor, then navigate to

HKEY_CURRENT_USER\Control Panel\Mouse

On the left-hand side of the screen is the key, and on right-hand side of the screen are all of the key's values and the data for each value. DoubleClickSpeed is of the type REG_SZ -- a string value, which means it's made up of numbers and/or letters and can be easily edited -- and its default measurement is 500 (milliseconds).

Now double-click DoubleClickSpeed. The Edit String box appears, as shown below, and the number 500 is highlighted.

ype in a number larger than 500, and Windows will let you be more leisurely in your double-clicks; type in a smaller number, and you'll have to double-click more quickly. (Windows, by the way, recognizes only a range of between 100 and 900 for this value.)

Change the number, click OK and then exit the Registry. Your change should go into effect immediately, although you may have to reboot or log off and then on again for it to take effect.
Adding keys and values
Editing the Registry often requires that you add new keys and values. Let's take an example. Say you're going to add a new key under

HKEY_LOCAL_MACHINE/Software/Classes/Folder/shell

called Command Prompt.

This key, as I describe in the story The ultimate tweaker's guide to Windows, will let you open a command prompt from the Windows Explorer right-click menu, and the command prompt will be at your current folder location.

First, navigate to HKEY_LOCAL_MACHINE
/Software/Classes/Folder/shell. Highlight the key and select Edit --> New --> Key.

When you create a new key, it will be added as New Key #1, which will be highlighted with your cursor next to it, as you can see below. (If for some reason New Key #1 isn't highlighted, right-click it and choose Rename, and you'll be able to rename it.)
Replace the highlighted text with the name of the key you want to create, in this instance, Command Prompt.
Once you've created the new key, you can add values to it as you can any other key. Create new values in a similar way to the way in which you create new keys. Navigate to the key for which you want to create a new value, choose Edit --> New and then choose the type of value you want to create, such as String Value.

The new value will appear as New Value #1 in the right-hand pane, and there will be no value yet associated with it. Rename your new value, then edit it as outlined earlier in this article.

Deleting keys and values
Deleting a key or value is even easier: Select it and press the Delete key.

No comments: