Working with Registry Keys and Settings


Now that you’ve had a look around, you’re ready to start working with the registry’s keys and settings. In this section, we’ll give you the general procedures for basic tasks, such as modifying, adding, renaming, deleting, and searching for entries, and more. These techniques will serve you well throughout the rest of the book when we take you through some specific registry modifications.

Changing the Value of a Registry Entry

Changing the value of a registry entry is a matter of finding the appropriate key, choosing the setting you want to change, and editing the setting’s value. Unfortunately, finding the key you need isn’t always a simple matter. Knowing the root keys and their main subkeys, as described earlier, will certainly help, and the Registry Editor also has a Find feature that’s invaluable. (We’ll show you how to use it later.)

To illustrate how this process works, let’s work through an example: changing your registered owner name and company name. During the Windows XP installation process, Setup may have asked you to enter your name and, optionally, your company name. (If you upgraded to Windows XP, this data was brought over from your previous version of Windows.) These “registered names” appear in several places as you work with Windows XP:

  • If you launch Control Panel’s System icon, your registered names appear on the General tab of the System Properties dialog box.

  • If you select Help, About in most Windows XP programs, your registered names appear in the About dialog box.

  • If you install a 32-bit application, the installation program uses your registered names for its own records (although you usually get a chance to make changes).

With these names appearing in so many places, it’s good to know that you can change either or both names (for example, if you give the computer to another person). The secret lies in the following key:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion

To get to this key, you open the branches in the Registry Editors tree pane: HKEY_LOCAL_MACHINE, then SOFTWARE, then Microsoft, and then Windows NT. Finally, click the CurrentVersion subkey to highlight it. Here you’ll see a number of settings, but two are of interest to us:

Tip

If you have keys that you visit often, you can save them as “favorites” to avoid trudging through endless branches in the keys pane. To do this, navigate to the key and then select Favorites, Add To Favorites. In the Add To Favorites dialog box, edit the name in the Favorite Name text box, if necessary, and then click OK. To navigate to a favorite key, open the Favorites menu and select the key name from the list that appears at the bottom of the menu.

  • RegisteredOrganization This setting contains the registered company name.

  • RegisteredOwner This setting contains your registered name.

    Now you open the setting for editing by using any of the following techniques:

  • Select the setting name and select Edit, Modify (or press Enter).

  • Double-click the setting name.

  • Right-click the setting name and select Modify from the shortcut menu.

The dialog box that appears depends on the value type you’re dealing with, as discussed in the next few sections. Note that edited settings are written to the registry right away, but the changes might not go into effect immediately. In many cases, you need to exit the Registry Editor and then either log off or restart Windows XP.

Editing a String Value

If the setting is a REG_SZ value (as it is in our example), a REG_MULTI_SZ value, or a REG_EXPAND_SZ value, you see the Edit String dialog box, shown in Figure 2-4. Use the Value Data text box to enter a new string or modify the existing string, and then click OK. (For a REG_MULTI_SZ multi-string value, Value Data is a multi-line text box. Type each string value on its own line. That is, after each string, press Enter to start a new line.)

click to expand
Figure 2-4: : You see the Edit String dialog box if you’re modifying a string value.

Editing a DWORD Value

If the setting is a REG_DWORD value, you see the Edit DWORD Value dialog box shown in Figure 2-5. In the Base section of the dialog box, select either Hexadecimal or Decimal, and then use the Value Data text box to enter the new value of the setting. (If you chose the Hexadecimal option, enter a hexadecimal value; if you chose Decimal, enter a decimal value.)


Figure 2-5: You see the Edit DWORD Value dialog box if you’re modifying a string value.

Editing a Binary Value

If the setting is a REG_BINARY value, you see an Edit Binary Value dialog box like the one shown in Figure 2-6.

click to expand
Figure 2-6: You see the Edit Binary Value dialog box if you’re modifying a binary value.

For binary values, the Value Data box is divided into three vertical sections:

  • Starting byte number The four-digit hexadecimal values on the left of the Value Data box tell you the sequence number of the first byte in each row of hexadecimal numbers. This sequence always begins at 0, so the sequence number of the first byte in the first row is 0000. There are 8 bytes in each row, so the sequence number of the first byte in the second row is 0008, and so on. These values can’t be edited.

  • Hexadecimal data The eight columns of two-digit numbers in the middle section display the setting’s value, expressed in hexadecimal numbers, where each two-digit number represents a single byte of information. These values are editable.

  • ASCII equivalents The third section on the right side of the Value Data box shows the ASCII equivalents of the hexadecimal numbers in the middle section. For example, in Figure 2-6 the first byte of the first row is the hexadecimal value 53, which represents the capital letter S. The values in this column are also editable.

Editing a .reg File

If you exported a key to a registration file, you can edit that file and then import it back into the registry. To make changes to a registration file, find the file in Windows Explorer, right-click the file, and then select Edit. By default, Windows XP will open the file in Notepad. Be aware that not all files having .reg for their file name extension are registration files.

Tip

If you need to make global changes to the registry, export the entire registry and then load the resulting registration file into WordPad or some other word processor or text editor. Use the application’s Replace feature (carefully!) to make changes throughout the file. If you use a word processor, be sure to save the file as a text file. You can then import the changed file back into the registry.

Creating a .reg File

You can create registration files from scratch and then import them into the registry. This is a handy technique if you have some customizations that you want to apply to multiple systems. To demonstrate the basic structure of a registration file and its entries, Figure 2 7 shows two windows. The top window is the Registry Editor with an example key named Test selected. The settings pane contains six example settings: the (Default) value and one each of the five common types of settings (binary, DWORD, expandable string, multi- string, and string). The bottom window shows the Test key in Notepad as an exported registration file (Test.reg).

click to expand
Figure 2-7: The settings in the Test key shown in the Registry Editor correspond to the data shown in Test.reg file shown in Notepad.

Windows XP registration files always start with the following header:

Windows Registry Editor Version 5.00
Tip

If you’re building a registration file for a Windows 9x, Windows Me, or Windows NT 4 system, change the header to the following:

REGEDIT4

Next is an empty line followed by the full path of the registry key that will hold the settings you’re adding, surrounded by square brackets:

[HKEY_CURRENT_USER\Test] 

Below the key are the setting names and values, which use the following general form:

Tip

If you want to add a comment to a .reg file, start a new line and begin the line with a semicolon (;).

 "SettingName"=identifier:SettingValue 

 SettingName 

This is the name of the setting. Note that the @ symbol used to represent the key’s (Default) value.

identifier

This is a code that identifies the type of data. REG_SZ values don’t use an identifier, but the other four common data types do:

 
dword

Use this identifier for a DWORD value.

 
hex

Use this identifier for a binary value.

 
hex(2)

Use this identifier for an expandable string value.

 
hex(7)

Use this identifier for a multi-string value.

SettingValue

This is the value of the setting, which you enter as follows:

 

String

Surround the value with quotation marks.

 

DWORD

Enter an eight-digit DWORD value.

 

Binary

Enter the binary value as a series of two-digit hexadecimal numbers, separating each number with a comma.

 

Expandable string

Convert each character to its hexadecimal equivalent and then enter the value as a series of two-digit hexadecimal numbers, separating each number with a comma, and separating each character with 00.

 

Multi-string

Convert each character to its hexadecimal equivalent and then enter the value as a series of two-digit hexadecimal numbers, separating each number with a comma, and separating each character with 00, and separating each string with space (00 hex).

Insider Secret

To delete a setting using a .reg file, set its value to a hyphen (-), as in this example:

Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Test]
"BinarySetting"=-

To delete a key, add a hyphen to the start of the key name, as in this example:

Windows Registry Editor Version 5.00 [-HKEY_CURRENT_USER\Test]

Renaming a Key or Setting

You won’t often need to rename existing keys or settings. Just in case, though, here are the steps to follow:

  1. In the Registry Editor, find the key or setting you want to work with and select it.

  2. Select Edit, Rename (or press F2).

  3. Edit the name and then press Enter.

    Caution

    Rename only those keys or settings that you created yourself. If you rename any other key or setting, Windows XP might not work properly.

Creating a New Key or Setting

Many registry-based customizations don’t involve editing an existing setting or key. Instead, you have to create a new setting or key. Here’s how you do it:

  1. In the Registry Editor, select the key in which you want to create the new subkey or setting.

  2. Select Edit, New. (Alternatively, right-click an empty section of the Settings pane and then select New.) A submenu appears.

  3. If you’re creating a new key, select the Key command. Otherwise, select the command that corresponds to the type of setting you want: String Value, Binary Value, DWORD Value, Multi-String Value, or Expandable String Value.

  4. Type a name for the new key or setting.

  5. Press Enter.

Deleting a Key or Setting

Here are the steps to follow to delete a key or setting:

  1. In the Registry Editor, select the key or setting that you want to delete.

  2. Select Edit, Delete (or press Delete). The Registry Editor asks if you’re sure.

  3. Click Yes.

Caution

Again, to avoid problems, you should delete only those keys or settings that you created yourself. If you’re not sure about deleting a setting, try renaming that setting instead. If a problem arises, you can then return the setting back to its original name.




Insider Power Techniques for Microsoft Windows XP
Insider Power Techniques for Microsoft Windows XP (Bpg-Other)
ISBN: 0735618968
EAN: 2147483647
Year: 2005
Pages: 126

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