Section 8.2. Adding and Deleting Registry Keys and Values


8.2. Adding and Deleting Registry Keys and Values

The Registry Editor, as mentioned earlier, is the primary tool for viewing, modifying, and deleting data in the Registry. And as you'll see later in this chapter, it also allows you to conveniently import and export data (via Registry patches), which can be thought of as another form of data entry.

Basic data entry in Registry Editor is fairly simple. In order to type data, you must first create a value to hold it. Depending on your goal, you may also need to create a new key in which to place the value.

To create a new key or value, use Edit New. The key or value then appears within the currently selected key, with the name New Key or New Value #1, respectively. A new string value will have the null string as its value; a new binary value will show the following message in parentheses: "(zero length binary value)." A new DWORD value will show up as zero: 0x00000000 (0) . You can then edit that value (see later in this chapter) to change it. New keys aren't created empty, either. They all contain the (Default) value described in the previous section.

To delete a key or value, select it and click Edit Delete, or simply press the Del key. But be warned , there's no undelete, so you might want to first write out the branch containing the key you're about to delete as a . reg file (see Section 8.5 and Section 8.6, later in this chapter). Or, you can use Edit Rename to rename the value or key. Since applications access values and keys by their names , renaming has the effect of disabling or "hiding" the item from the application that uses it, while preserving its data.

To edit a value, double-click on its icon or name, or highlight it and use Edit Modify. You will see an edit box appropriate to the value type. When editing a string value, Registry Editor provides a standard text box, in which you can type text, as well as copy and paste (by right-clicking on the text, or by using Ctrl-C, Ctrl-X, and Ctrl-V). Binary values have a more complicated and less familiar edit dialog, which allows data entry via ASCII codes on the left, or plain text on the right. Finally, DWORD values have a simpler edit interface, providing only for entry of a single number (either in Hex or Decimal format). Cut, Copy, and Paste work in DWORD and Binary dialogs as well. See the previous section, Section 8.1, for more details on the different types of values.

Unfortunately, automation in Registry Editor is virtually nonexistent. For example, you can't copy and paste whole keys or values like you might expect (given the familiar Explorer-like interface), but you can copy key and value names to the clipboard by pretending you're going to rename them, and then pressing Ctrl-C to copy. Another useful tool is the Copy Key Name command on the Edit menu, which copies the full path to the selected key to the Clipboard (very handy for writing this book, for example). It doesn't copy the contents of the key, nor does it include the selected value, however.

If you want to duplicate an existing value, double-click it and select all of the data in the Edit window (see Figure 8-4).

Figure 8-5. Copying an existing Registry value

Ctrl-C will copy the data to the clipboard. Then create a new value, being sure to match the type (string, binary, or DWORD) of the original value. Type the desired value name, double-click the new value to edit it, and then use Ctrl-V to paste the copied data into the edit window.

Duplicating values can be handy not only when using an existing value as a template for a new value, but also whenever you're going to make changes to an existing value. You can make little "inline backups " by creating a new value ( whatever .bak , for instance) and pasting in the old value data before you change it. This might seem a little tedious , but it might prevent future headaches if you're about to change a complex value whose format you aren't completely sure you understand, or even if you anticipate having to roll back a value to its previous state for some reason.

Unfortunately, there's no easy way to copy a key and all of its contents in Registry Editor. If you want to copy an entire key and all its values, you'll have to do it one value at a time. It's usually much easier to export the key, edit the resulting file with a text editor, and then import the edited file. (See Section 8.6 later in this chapter.)

In addition to the Edit menu, you may find Registry Editor's context menus convenient . Right-clicking on a key in the left pane gives a context menu with Expand or Collapse, New, Find, Delete, Rename, and Copy Key Name. (Expand displays a key's subkeys. It will be grayed out if there are no subkeys to display, and it will be replaced with Collapse if said subkeys are already showing.) Right-clicking with a value selected in the right pane gives a context menu with Modify, Delete, and Rename. Right-clicking in the right pane with no value selected gives a context menu with New (to create a new string, binary, or DWORD value). Press Shift-F10 to open a context menu without having to use the mouse.



Windows XP in a Nutshell
Windows XP in a Nutshell, Second Edition
ISBN: 0596009003
EAN: 2147483647
Year: 2003
Pages: 266

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net