3.2 Registry Tips and Solutions
The solutions in the rest of this chapter concern the
Registry Editor and other topics related to the Windows Registry.
3.2.1 Using Registry Patches
In addition to editing the Registry with the Registry Editor
(see earlier in this chapter), you can make changes by using Registry patches. A
Registry patch is simply a text file with the .reg extension that
contains one or more Registry keys or values. If you double-click on a .reg
file, the patch is "applied" to the Registry, meaning that the contents of the
patch are merged with the contents of the
Registry. This tool is especially handy for backing up small portions of the
Registry or distributing Registry settings to other computers.
For example, if a particular application stores its custom
toolbar in the Registry, you can use a Registry patch to copy the toolbar to
another computer, saving time that would otherwise be spent painstakingly
configuring the 431 toolbar items on the new machine.
A Registry patch is also a handy way to back up Registry
data, such as file types, which are constantly at risk of being changed by other
applications (see Section 4.3.3). More importantly, however, Registry patches
can be used to back up portions of the Registry to safeguard them against
modifications you're about to make, such as the modifications suggested
throughout the rest of this book.
3.2.1.1 Create a Registry patch
-
Open the Registry Editor, and select a branch you wish to
export.
The branch can be anywhere from one of the top level
branches to a branch a dozen layers deep. Registry patches include not only
the branch you select, but all of the values and subkeys in the branch. Don't
select anything more than what you absolutely need.
-
Select Export from the
File menu, type a filename, and press
OK.
All of the values and subkeys in the selected branch will
then be stored in the patch file. Make sure the filename of the new Registry
patch has the .reg extension.
Creating a Registry patch is the easy part; the hard part can
be determining the Registry key to be exported in the first place. See Section
3.2.2 later in this chapter for details.
Once you've created the patch, you can modify it or apply it
to your (or someone else's) system, as described in the following sections.
3.2.1.2 Edit a Registry patch
Since Registry patches are just plain text files, you can
edit them with any plain-text editor, such as Notepad (notepad.exe). The
contents of the Registry patch will look something like the text shown in
Example 3-1.
Example 3-1. Contents of a Registry patch created
from HKEY_CLASSES_ROOT \.txt
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.txt]
@="txtfile"
"PerceivedType"="text"
"Content Type"="text/plain"
[HKEY_CLASSES_ROOT\.txt\ShellNew]
"NullFile"=""
The first line, Windows Registry Editor Version 5.00,
tells Windows that this file is a valid Registry patch; don't remove this line.
The rest of the Registry patch is a series of key names and values.
The key names appear in brackets ([...]) and specify
the full path of the key. The values contained within each key follow. The name
of the value is given first, followed by an equals sign, and then the data
stored in each value. The value names and value data are always enclosed in
quotation marks. A value name of @ tells the Registry Editor to place
the value data in the (default) value (as shown in the fourth line of
the example).
 |
Registry patches created in Windows 95, 98, or Me
will have the line REGEDIT4 at the top of the file. These
patches can be imported into the Windows XP Registry without a problem
(that is, not taking into account the settings contained therein).
However, older versions of Windows may complain if you try to import
Registry patches created in Windows XP. If you encounter this problem,
just replace the header line with REGEDIT4. |
|
If you are familiar with the particular information contained
within the Registry patch you've just created, you can edit anything you wish
and save the changes when you're done. Note that only making changes to a
Registry patch doesn't mean anything; your changes won't take effect in the
Registry until the Registry patch is applied (described in the next section).
There are several reasons why you might want to edit a
Registry patch file:
- Streamline a lot of edits
-
Modifying a large number of Registry values may turn out to
be much easier with a text editor than with the Registry Editor, since you
don't have to open—and then close — each individual value.
Keep in mind that if you change the name of a value (to the
left of the equals sign), as opposed to the value contents (on the right
side), you'll be effectively creating a new value. See the next section for
details on how Registry contents are merged.
- Search and replace
-
The Registry Editor has no search-and-replace function (for
reasons that shouldn't need explaining). However, most text editors do, so you
could quite easily search for and replace text when editing a Registry patch.
If you have a branch of settings you wish to change—for
example, if you've moved an application from one drive to another—you can use
a Registry patch. Just create a patch of the branch in question and use your
favorite text editor's search-and-replace feature to change the values in the
patch (for example, replace all occurrences of c:\big_program with
e:\big_program). When you apply the patch, all the settings will be
changed for you.
Note that it's very easy to change more than you intended
with a search-and-replace, so be careful. However, one of the benefits of
Registry patches is that you can double-check your changes before they're
applied to your Registry. Also, a second Registry patch can be used to easily
restore the modified portion of the Registry if necessary. See Section 3.2.3
later in this chapter for more tips.
If you find yourself wanting to use search and replace more
often, you may want to try the Registry Search and Replace utility; see
Section 3.2.6 at the end of this chapter for more information.
- Easily duplicate keys and branches
-
The Registry Editor provides no way to copy or move a key
(such as using drag-drop). If you create a
Registry patch of a key, change the key name, and then re-import it, it will
effectively duplicate the key. This can be a handy way to create new file
types (described in Chapter 4).
- Automate the deletion of Registry data
-
Lastly, there's really no way, using the Registry Editor,
to create a patch that deletes a Registry key
(think about it). However, you can modify a Registry patch to accomplish this
feat.
To delete a key with a Registry Patch, place a minus sign
before the key name, like this:
-[HKEY_CURRENT_USER\Control Panel\don't load]
If you delete a key, all of its values will also be
deleted. However, a security feature present in Windows XP
prevents the removal of any key that currently has sub-keys. This means that
to remove an entire branch, you'll have to recursively delete all of the
subkeys first, which is something typically only possible from within a
programming language.
To delete a value with a Registry Patch (but leave the key
untouched), place a minus sign after the
equals sign, like this:
[HKEY_CURRENT_USER\Control Panel\don't load]
"desk.cpl"=-
- Merging multiple patches
-
One of the advantages of Registry patches is that they
enable you to change several Registry settings in a single step. However,
sometimes those settings are located in different parts of the Registry, and
since it isn't practical to export the entire Registry just to catch all of
the applicable keys, you can quite easily merge two different Registry patches
into a single file. See Section 4.3.3 for a practical example.
3.2.1.3 Apply a Registry patch
You can apply a Registry patch at any time and to any
computer. There are three ways to do this, but there is really no difference
between them, at least as far as the final results are concerned. Do whatever is
most convenient.
3.2.1.4 Solution 1: from Explorer
-
Double-click on a Registry patch file (with the .reg
extension) in Explorer or on your desktop. It doesn't matter if the Registry
Editor is running or not.
-
Answer Yes to the warning
message that asks, "Are you sure you want to add the information in
c:\stuff\MyPatch.reg to the Registry?"
Immediately thereafter, you'll see the message,
"Information in MyPatch.reg has been successfully entered into the
Registry."
3.2.1.5 Solution 2: from within the Registry Editor
-
Select Import from the
File menu, and select the patch you wish to
import.
-
Click OK to merge the
file. You won't be prompted to confirm that you actually do want to apply the
patch (as with Solution 1), but you will receive the confirmation message
informing you the patch was successful.
3.2.1.6 Solution 3: from the command line
-
Open a Command Prompt window (cmd.exe).
-
Using the cd command, as described in Appendix C,
navigate to the folder containing the Registry patch. Note that instead of
changing the working directory, you can also simply specify the full path of
the patch in the next step.
-
Assuming the Registry patch is named MyPatch.reg,
type the following:
regedit mypatch.reg
You'll then receive the same "Are you sure?" message, as
when double-clicking the Registry patch in solution 1. However, the advantage
of using the command line is the ability to apply Registry patches from a WSH
script or batch file, so the preferred method is to bypass the confirmation,
like this:
regedit /s mypatch.reg
where the /s switch instructs the Registry Editor
to import the patch silently (without the prompt).
If the Registry Editor is currently running and you are
viewing a key that was modified by a patch that was just applied, RegEdit should
refresh the display automatically to reflect the changes. If it doesn't, press
the F5 key or go to
View
Refresh.
 |
When you apply a Registry patch, you are
merging the keys and values stored in a
patch file with the Registry. Any keys in the applied patch
that don't already exist will be added
to the Registry. Pre-existing keys in the patch will be left alone. If a
specific value already exists, the value will be changed to whatever is
in the patch. However, any values already in an existing key that
aren't in the Registry patch will
remain. This means that if you create a patch, rename a key or value
(different from changing its data), and then apply it, the original key
or value will remain intact, and you'll have a duplicate. |
|
If you're creating a Registry patch on your computer for use
on another, make sure any folder names or drive letters are corrected for the
new computer. If, for example, a Registry patch created on one computer
references c:\my_ folder\my_ program.exe, you'll need to make sure to
change all occurrences of the text to d:\her_ folder\my_ program.exe to
reflect any applicable differences. Using Expandable String values, as described
earlier in this chapter, virtually eliminates this problem.
See Chapter 9 for a discussion on the Windows Script Host,
which documents how to further automate changes to the Registry.
3.2.1.7 Using Registry patches on earlier versions
of Windows
Many of the Registry patches you create and modify in Windows
XP will be applicable in other versions of Windows. But there are two issues
you'll need to address before you can use Registry patches on a computer running
Windows 9x/Me:
- Unicode versus ANSI
-
Registry patches created in Windows XP and Windows 2000 are
encoded as Unicode text, a format not supported by the Registry Editor in
Windows 9x/Me. Unless you convert these files to ANSI or ASCII files, they'll
just show up as jibberish in earlier versions of Windows.
- The header
-
As stated previously, the single-line header placed at the
beginning of every Registry patch in Windows XP is Windows Registry Editor
Version 5.00. If you change this to REGEDIT4, the Registry
patch will be readable in Windows 9x/Me, as well as Windows 2000/XP.
Here's a quick procedure to convert a Registry patch created
in Windows XP so that it can be used in Windows 9x/Me. Note that this procedure
won't stop Windows XP and Windows 2000 from recognizing the patches, which makes
one wonder why Microsoft changed the format.
-
Open a newly-created Registry patch file in Notepad (notepad.exe).
-
Remove the line that reads:
Windows Registry Editor Version 5.00
and replace it with the following:
REGEDIT4
-
Go to File
Save As, and choose
ANSI from the Encoding list at the bottom of the
Save As dialog. Make sure the filename is
correct, and click Save when you're done.
 |
You can also save Registry patches for use in
earlier versions of Windows right in the Registry Editor. Go to
File
Export, and then choose
Win9x/NT 4 Registaration Files from
the Save as type list. |
|
Despite the different format, Registry patches are applied in
the same way in all versions of Windows. Refer to the instructions earlier in
this section for details.
3.2.2 Finding the Right Registry Key
The two main obstacles you'll encounter when trying to make a
change to the Registry are (1) where a setting is located in the Registry, and
(2) what modifications are necessary to affect the desired changes.
Sometimes it's obvious, such as a theoretical value called
ShowSplashScreen, with its contents set to 1 (one); changing
the 1 to a 0 (zero) would most likely result in turning the
option off. Other times you'll see a long,
seemingly meaningless series of numbers and letters. Although there are no
strict rules as to how values and keys are named or how the data therein is
arranged, a little common sense and intuition will get you through most
situations.
Here's a solution that will help you find the corresponding
Registry key for a particular setting in Windows. For this example, we'll find
the Registry setting associated with showing or hiding hidden files in Explorer,
and then we'll create the appropriate Registry patch.
 |
A Registry patch is a convenient way of automating
changes to the Registry, and therefore to Windows and your applications,
and is useful if you frequently change a setting or a group of settings.
It's also a convenient way to propagate a group of settings to one or
more other computers. This solution provides a way to come up with a
Registry patch that corresponds to one or more options in the interface.
|
|
The idea is to take snapshots
(make Registry patches) of your entire Registry before
and after a change is made in Explorer (or
another program). By comparing the two snapshots, we can easily see which
Registry keys and values were affected:
-
Make sure no unnecessary applications are running (check
your tray), because they could write to the Registry at any time, adding
unexpected changes.
-
Open the Registry Editor, and highlight the
HKEY_CURRENT_USER branch. Select Export
Registry File from the Registry menu,
and export the entire branch to a file called User1.reg (or something
like that), stored somewhere convenient, such as your desktop.
Then, select the HKEY_LOCAL_MACHINE branch and
repeat the steps, exporting it instead to Machine1.reg.
-
Next, we will make our desired change. In this case, go to
Control Panel
Folder Options
View tab. In the
Advanced Settings list, change the Hidden
Files and Folders option, and click OK
when you're done.
-
Immediately switch back to the Registry Editor, and
re-export the HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE
branches into new files, such as User2.reg and Machine2.reg,
respectively, as described earlier in step 2.
-
What we now have is a snapshot
of the entire Registry taken before and after the change (or changes) was
made. It's important that the snapshots be taken immediately before and after
the change, so that other trivial settings, such as changes in Explorer window
positions, aren't included with the changes we care about.
-
All that needs to be done now is to distill the
changed information into a useful format.
Windows comes with the command-line utility, File Compare ( fc.exe),
which can be used to find the differences between our
before and after
files.
At the command prompt, first use the cd command to
change to the directory containing the Registry patches (such as
\Windows\Desktop, if they're on your desktop—see Appendix C for more
information on the cd command), and then type the following two
lines:
fc /u user1.reg user2.reg > user.txt
fc /u machine1.reg machine2.reg > machine.txt
-
These commands will instruct File Compare to scan both
pairs of files and write only the differences
between the files into new text files: user.txt for the changes in
HKEY_CURRENT_USER and machine.txt for the changes in
HKEY_LOCAL_MACHINE.
The user.txt file should look something like this:
Comparing files user1.reg and USER2.REG
***** user1.reg
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\Advanced]
"Hidden"=dword:00000001
"ShowCompColor"=dword:00000000
***** USER2.REG
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\Advanced]
"Hidden"=dword:00000002
"ShowCompColor"=dword:00000000
*****
From this example listing, it's evident that the only
applicable change was the Hidden value, located deep in the
HKEY_CURRENT_USER branch. (There may be some other entries, but if you
inspect them, you'll find that they relate only to MRU lists from RegEdit and
can be ignored.)
Note that for this particular setting no changes were
recorded in the HKEY_LOCAL_MACHINE branch, so machine.txt ends
up with only the message, "FC: No differences encountered." This
means our changes were only reflected in the HKEY_CURRENT_USER
branch.
-
You'll also notice that the lines immediately preceding and
following the line we care about are also shown; they're included by FC as an
aid in locating the lines in the source files. We're lucky in that one of the
surrounding lines in this example happens to be the section header (in
brackets), which specifies the Registry key in which this value is located.
In most cases, you'll have to search the Registry snapshots
(often easier than searching the Registry) for the changed line; for this
example, you'd search USER2.REG for "Hidden"=dword:00000002
and then make note of the line enclosed in square brackets ([...])
most immediately above the changed line. This
represents the key containing the Hidden value.
In user2.txt, the Hidden line is located in
the section:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\Advanced]
-
The next step is to convert the output from File Compare
into a valid Registry patch. Because the FC output is originally derived from
Registry patches, it's already close to the correct format. Start by removing
all of the lines from user.txt, except the
second version of the changed
line—this would be the value in its after
setting, which presumably is our goal. You'll end up with this:
"Hidden"=dword:00000002
-
Next, paste in the key (in brackets) above the value. (In
the case of our example, it was part of the FC output and can simply be left
in.) You should end up with this:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\Advanced]
"Hidden"=dword:00000002
-
Lastly, add the text Windows Registry Editor Version
5.00 followed by a blank line at the beginning of the file (see Section
3.2.1.2, earlier in this chapter, for more information). The final result
should look something like this:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\
Explorer\Advanced]
"Hidden"=dword:00000002
-
Save this into a new file called User-final.reg (or
something like that).
If the settings you've changed have resulted in changes in
the HKEY_LOCAL_MACHINE branch, simply repeat steps 9-12 for the
machine.txt file as well.
-
If your setting resulted in changes in both
HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE, your last step would
be to consolidate the two patches into one file. See Section 4.3.3 for a
practical example of how this is done. When consolidating, make sure you have
only one instance of the Windows Registry Editor Version 5.00 line.
For some settings (such as the one in this example), you may
want to make two patches: one to turn it on, and one to turn it off. Simply
double-click the patch corresponding to the setting you desire.
You may notice that some changes involve the actual removal
of a key or value, instead of simply the modification of an existing entry. See
Section 3.2.1.2, earlier in this chapter for details on automating the deletion
of Registry data.
This solution will help you find the appropriate keys and
values associated with a particular Windows or application setting, and it can
also help locate hidden settings (those with
that don't appear in dialog boxes). The setting in the previous example is
located in a key that contains other settings, some of which aren't included in
the Folder Options dialog box. Experiment with some of the more interesting
sounding values, such as CascadePrinters and ShowSuperHidden.
There are some caveats to this approach, mostly in that the
File Compare utility will often pull out more differences than are relevant to
the change you wish to make. It's important to look closely at each key in the
resulting Registry patch to see if it's really applicable and necessary.
See Chapter 9 for a discussion on the Windows Script Host,
which documents automating changes to the Registry that don't involve Registry
patches.
 |
It's always smart to create a corresponding
undo Registry patch while you're using
a solution like this. For example, because our Registry patch contains
the differences in the after file,
user2.reg, the corresponding undo
patch would contain the corresponding lines in the
before file, user1.reg. Applying
the undo patch effectively returns the
keys and values stored within to their state before the setting was
changed. Obviously, an important caveat is that an undo patch for one
computer won't necessarily be an effective undo for another computer.
|
|
3.2.3 Search the Registry Effectively
The Registry Editor has a simple search feature, allowing you
to search through all the keys and values for text. Just select
Find from the Registry Editor's
Edit menu, type the desired text, and click
Find Next.
Because the Registry can become quite large and have a wide
variety of settings and information, it is important to learn to search
effectively, so you don't miss anything, nor waste a lot of time wading through
irrelevant results. Additionally, the Registry Editor doesn't have a
search-and-replace feature, so doing something as simple as changing every
occurrence of c:\program files to d:\program files can be a
monumental chore. Here are some tips that may help:
-
Make sure that all three options in the
Find window's Look
at section are checked, unless you know specifically that what you're
looking for is solely a Key,
Value (value name), or
Data (value contents).
You'll also usually want the
Match whole string only option turned off, unless you're searching for
text that commonly appears in other words; searching for handle might
otherwise trigger entries like PersistentHandler and TeachAndLearn.
-
Many folder names in the Registry are stored in both long
and short versions. For example, say you
want to move your Program Files folder from one drive to another. When
you install Windows, any settings pertaining to this folder may be stored in
the Registry as c:\Program Files or c:\Progra~1. Make sure you
search for both.
If you're searching the Registry for both Program
Files and Progra~1, you may want to just search for
progra, which will trigger both variations. Because this will trip upon
other uses of the word program, try placing a backslash (
\ ) in front of it, like this: \progra, to limit the search to
only directory names beginning with those letters. A minute of mental
preparation can save you an hour of searching.
-
You may want to search the Registry for an interface
element, such as a new item added to a context menu or text in a list in a
dialog box. If the text contains an underlined character,
you'll need to add an ampersand (&) to the search string. For
example, say you've installed a program that creates .zip files (such
as WinZip;
http://www.winzip.com), and the program has added the command
Add to Zip (with the Z underlined) to the
context menu for all files. You'll need to search for add to
&zip to match the text properly; a search for add to
zip will probably turn up nothing. Note also that text searches are
not case-sensitive, so you don't have to
worry about capitalization.
-
Searching begins at the currently selected key. If you want
to be sure to search the entire Registry, make sure the My
Computer entry at the top of the Registry tree is highlighted before you
begin. However, if you know the setting you want to change is in, for example,
HKEY_LOCAL_MACHINE, you should highlight that key beforehand to
reduce search time and eliminate irrelevant results.
-
Although the Registry Editor has a search feature, it
doesn't allow you to search and replace. If you have a branch of settings you
wish to change (for example, if you've moved an application from one drive to
another or want to, say, replace every occurrence of notepad.exe with
another application), you can use a Registry patch—see Section 3.2.1 earlier
in this chapter. Just create a patch of the branch in question and use your
favorite text editor's search-and-replace feature to change the values in the
patch. When you apply the patch, all the settings will be changed for you.
Note that you should use this with caution, because you can screw up many
settings unwittingly by searching and replacing common pieces of text.
If you find yourself wanting to use search and replace more
often, and the previous Registry patch tip isn't sufficient, you may want to
try the Registry Search and Replace utility; see Section 3.2.6 at the end of
this chapter for more information.
3.2.4 Using INI Files
If you've been using a Windows PC for any length of time,
you've probably come across files with the .ini filename extension.
Initialization files (or Configuration Settings, as they're known in any recent
release of Windows) were used in the old days to store settings for
applications, as well as Windows itself, before the Registry was implemented.
INI files are simply text files (editable with any plain-text editor, such as
Notepad) that are specially formatted to store such settings. Because INI files
are limited in their maximum file size (64 KB) and are not as efficient as the
Registry, application developers have been strongly encouraged to abandon INI
files and instead store settings in the Registry. Since some applications still
use INI files to store certain settings, it may become necessary to look for and
change settings in INI files as well.
An example of an application that may still use an INI file
today is an application installer. An INI file would allow a program to read and
store settings without having to rely on the Registry; that way, the settings
would be accessible regardless of the computer on which the program was run. INI
files are also handy (for the same reason) for programs that run over a network.
Windows also includes a few INI files, although they're generally used only to
maintain compatibility with older applications.
To edit an INI file, just double-click it, and it will open
in Notepad. A typical INI file looks
something like this:
[Episodes]
2F01=The Last Traction Hero
9F22=Spay Anything
4f12=Why do Fools fall in Lava?
7F09=Porch Pals
[Cities]
first=Brockway
second=Ogdenville
third=North Haverbrook
Section names are always enclosed in square brackets ([...]);
the lines that follow are the settings contained in that section. A section
continues until the next section begins or the file ends. Settings include a
setting name, followed by an equals sign, and then the data assigned to that
setting.
You'll notice that the structure of INI files is similar (but
not identical) to that of Registry patches, discussed earlier in this chapter.
3.2.4.1 Searching INI files for settings
In addition to searching the Registry, you may want to search
all INI files for a particular setting:
-
Open a Search window (see Chapter 2).
-
Type *.ini in the
All or part of the file name field, and type the text for which you
want to search in the A word or phrase in the file
field.
-
Double-click on any file in the search results to view it,
and use your text editor's search feature to find the specific instance of
text in the file.
3.2.4.2 Special case: System.ini and Win.ini
INI files can be found in a variety of places; some
applications place their INI files in the application folder, while others store
them in the Windows folder (the preferred location, recommended by Microsoft
many years ago). Although it's becoming less common, some applications store
their settings in the file, Win.ini, which is the INI-file equivalent of
the HKEY_USERS branch of the Registry.
Right alongside Win.ini is the System.ini file,
the INI-file equivalent of the HKEY_LOCAL_MACHINE Registry branch. Both
of these files are still included in Windows XP, although it's primarily to
maintain compatibility with such older applications that expect to find or store
certain settings therein.
There's typically little interest anymore in either of these
files. If you're familiar, for example, with the now-obsolete Load= and
Run= lines in the [Windows] section of Win.ini, that
functionality is taken care of by the Startup folder in the Start Menu,
as well as several locations in the Registry (see Chapter 6 for details.).
Similarly, the shell= line of System.ini, which was used to
specify an alternate Windows shell (replacing Program Manager in Windows 3.x or
Explorer in Windows 95) is no longer supported at all in Windows XP.
3.2.5 Create an Interface for a Registry Setting
The whole point of accessing the Registry is to view and
modify settings that are otherwise inaccessible in Explorer, the Control Panel,
or the hundreds of dialogs boxes scattered throughout the operating system.
However, there is a way to patch into the interface and add checkboxes and radio
buttons that are linked to whatever Registry settings we want.
Start by going to Control Panel
Folder Options
View menu. At first glance, the
Advanced settings list in this dialog box is
presented in a somewhat awkward list format, apparently to accommodate the large
number of options. However, the less-than-ideal presentation is actually
designed to allow customization, permitting Microsoft (or you) to easily add or
remove items from the list. See Figure 3-3 for an example of a customized
version of this window.

Although the "customizability" of this dialog isn't
necessarily intended for you to add an option for any Registry setting you want,
whether it's related to Explorer or not, that's precisely what you can do with
it, thanks to the following solution.
The idea is that you link up a checkbox or radio button to a
value—any value you choose—in your Registry. This would, for example, allow you
to make certain Registry changes accessible to yourself or others (such as users
in a workgroup that you administer), reducing the need for them to mess around
in the Registry. You can also remove any unwanted options that normally appear
here, but that you don't want easily changed.
The format is actually quite remarkable, because you don't
have to be a programmer to utilize this feature. You can add new options to a
certain portion of the Registry and then tie those options to other Registry
settings. The downside is that the syntax requires that numerous parameters be
typed, which can be cumbersome. The following procedure should allow you to make
changes to existing settings, as well as add your own settings fairly easily:
-
Open the Registry Editor.
-
Expand the branches to: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder.
Notice that the actual hierarchy in the Folder Options
window is reproduced here in the Registry, although the list items may appear
in a different order than their corresponding Registry entries. This is
because the captions in the Folder Options list aren't necessarily the same as
the names of the corresponding Registry keys here, yet both collections are
sorted alphabetically. For example, the Remember
each folder's view settings option is represented by the
ClassicViewState key in the Registry.
-
Take this opportunity to back up the entire branch by
highlighting the Advanced key and selecting
Export from the File menu. This way,
you'll be able to easily restore the defaults without having to reinstall
Windows.
-
At this point, you can remove any unwanted entries by
deleting the corresponding keys from this branch; the Text value in
each key should be enough to explain what each key is for.
-
To add a new item, start by simply creating a new key,
keeping the hierarchy in mind—for example, are you adding a setting to the top
level, or possibly a new setting to an existing group, or are you creating a
new group for additional options?
Name the key anything you want, although the more
descriptive, the better.
-
The values inside each key determine the properties of the
corresponding setting. For example, one value affects the caption, while
another affects the default value. Feel free to fish around the existing keys
for examples.
To add a property, create a new value, name it
appropriately (described later), double-click it, and then type the contents
for the value. Table 3-2 lists the properties that affect the visual
appearance of a specific item, and Table 3-3 lists the properties that affect
what happens when a specific item is turned on or off in the Folder Options
window.
Table 3-2. Visual properties of Folder Options
items
|
Type |
String |
This can be set to either group, checkbox,
or radio, representing a folder, checkbox, or radio button,
respectively. Checkboxes are square options and can either be either on or
off. Radio buttons are round options that are linked to other radio
buttons in the same folder, in that only one at a time can be selected
(you can have multiple groups of radio buttons). And folders, of course,
are used to organize the various other options. This parameter is required
by all items. |
|
Text |
String |
This is the actual caption of the option as it will
appear in the dialog box. This can be as long as you want (better too
descriptive than too vague), but the paradigm dictates that only the first
word be capitalized and that there be no period. This parameter is
required by all items. |
|
Bitmap |
String |
This specifies the icon, used for folder items only. If
omitted, it's a rather ugly bent arrow. The syntax
is filename,index, where filename
is the full path and filename of the file containing the icon, and
index is the icon number (starting with zero), if the file
contains more than one icon. To specify the familiar yellow folder, type
%SystemRoot%\system32\Shell32.dll,4 here. This parameter is
optional for all folders, and has no effect on checkboxes and radio
buttons. |
|
HelpID |
String |
This is the filename and optionally the help context
ID, pointing to the documentation for this item. If the user selects the
item and presses the F1 key, this specifies the help note that will
appear. The syntax is filename#id, where
filename is the name of a .hlp or .chm file,
and id is the numeric help context id (commonly used by
programmers) of the topic you want to display. Omit id to
simply show the index page of the specified help file. This parameter is
optional. |
Table 3-3. Registry-related properties of Folder
Options items
|
HKeyRoot |
DWORD |
This is an eight-digit number representing the root of
the Registry path containing the target Registry setting. Use the
hexadecimal number 80000000 for
HKEY_CLASSES_ROOT, 80000001 for HKEY_CURRENT_USER,
80000002 for HKEY_LOCAL_MACHINE, 80000003 for
HKEY_USERS, or 80000005 for HKEY_CURRENT_CONFIG.
For some reason, it must be separated from the rest of the Registry path,
specified in RegPath, later. This parameter is required for all
checkbox and radio items. |
|
RegPath |
String |
This is the path specifying the location of the target
Registry setting, not including the root (see HKeyRoot, earlier).
For example, for HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion,
you would only enter Software\Microsoft\Windows\CurrentVersion
here. This parameter is required for all checkbox and radio items. |
|
ValueName |
String |
This is the name of the target Registry value. This
value is where the setting data is stored when the option is turned on or
off in the Folder Options window. The key containing said value is
specified by the RegPath and HKeyRoot parameters, listed
earlier. This parameter is required by all checkbox and radio items. |
|
CheckedValue |
Should match target value datatype |
This holds the data to be stored in the target Registry
value (specified by the RegPath and ValueName parameters
earlier), when said option is turned on.
If you're configuring an option to be used on both Windows 9x/Me and
Windows XP/2000 systems, use both the CheckedValueW95 and
CheckedValueNT parameters instead of this
value. This parameter is otherwise required by all checkbox and
radio items. |
|
CheckedValueW95 |
Should match target value datatype |
Use this instead of CheckedValue, above, if
you're configuring an option to be used on both Windows 9x/Me and Windows
XP/2000 systems. This value contains the data that will be applied if the
system is running Windows 9x/Me. Used in conjunction with
CheckedValueNT, below. |
|
CheckedValueNT |
Should match target value datatype |
Use this instead of CheckedValue, above, if
you're configuring an option to be used on both Windows 9x/Me and Windows
XP/2000 systems. This value contains the data that will be applied if the
system is running Windows XP, 2000, or NT. Used in conjunction with
CheckedValueW95, later. |
|
UnCheckedValue |
Should match target value datatype |
This holds the data to be stored in the target Registry
value, when said option is turned off.
This value is optional; if omitted, it is assumed to be 0. |
|
DefaultValue |
Should match target value datatype |
This is the default value, used only if the target
Registry value does not already exist. As soon as the option in the Folder
Options window is turned on or off at least once, this parameter is
ignored, and Windows instead reads the state of the target value,
comparing it to CheckedValue and UnCheckedValue to
determine if the option should appear checked or unchecked. This value is
optional; if omitted, it is assumed to be 0. |
The value type (String, Binary, DWORD) of the
CheckedValue, UnCheckedValue, and DefaultValue
parameters all depend on what the target value requires. For example, if the
target value you're changing is a DWORD value, then all three of
these parameters must also be DWORD values.
-
After you've created keys and entered the appropriate
property values, your Registry should look something like Figure 3-4, and the
resulting Folder Options window should look like Figure 3-3. If the Folder
Options window is open, you'll have to close it and re-open it for the changes
to take effect.
If you try to add a setting using the previous procedure
and it doesn't show up in Folder Options, most likely one or more required
values are missing.
-
Close the Registry Editor when you're finished.

The examples shown in Figure 3-3 and Figure 3-4 shows how
another solution in this book (see the discussion of the Recycle Bin in Section
4.1.1) can be turned into an advanced Folder Options setting. Here, a single
checkbox allows you to easily turn on and off the Rename and Delete
commands in the Recycle Bin's context menu.
When the Folder Options dialog box is first displayed, each
option is set according to the current value of the corresponding settings. More
specifically, the current data stored in each target value is compared with the
corresponding CheckedValue and UnCheckedValue, and the option
in the Advanced settings list is set
accordingly. When the OK button is pressed in
Folder Options, the settings in the Registry are then written using the same
criteria.
To reproduce a setting elsewhere in the Windows interface or
the interface of a third-party application, you'll first need to find the
respective Registry setting—see Section 3.2.2, earlier in this chapter, for more
information. Refer also to the section on Registry patches, which offer a very
handy way to reproduce the customizations made here on any number of computers.
3.2.6 Registry Tools
The Registry Editor is included with Windows for viewing and
changing the contents of the Registry. Unfortunately, this utility is quite
limited, especially when compared with some of the other tools available. The
following is a list of a few software utilities intended for use with the
Registry, available at the time of this writing. Naturally, you'll want to back
up your Registry before ever playing with an unfamiliar tool. See
http://www.annoyances.org/ for download links to most of the software
recommended in this book:
- Registry Search and Replace (version 2.15 or
later)
-
This tool is used to make a global search and replace in
the Registry much easier and quicker. Its interface could use a little
streamlining, but otherwise it does the job.
- TweakUI
-
The options in this little Microsoft add-on make certain
Windows settings more accessible, settings that would otherwise require
editing the Registry. Note that the version of TweakUI used with older
versions of Windows should not be used in Windows XP. TweakUI is available
from
http://www.annoyances.org. See Appendix A for more information.
- Creative Element Power Tools
-
This collection of tools for Windows XP, Windows 2000, and
Windows Me includes a bunch of settings, utilities, and context-menu add-ons
that aren't otherwise possible with simple changes to the Registry.
|
Main Menu
|