'; window.popUpWin.document.write(zhtm); window.popUpWin.document.close(); // Johnny Jackson 4/28/98 } //--> Windows 98 Professional Reference -- Ch 10 -- Mastering the Windows 98 Registry


Windows 98 Professional Reference

Previous chapterNext chapterContents


- 10 -
Mastering the Windows 98
Registry



As a computer professional working with Windows 98, you really need to master the Windows 98 Registry to earn your wings. In a sense, the Windows 98 Registry is the foundation on which Windows 98--and its applications--run. Becoming proficient with the Registry is one of the things that set support professionals above their peers.

You'll undoubtedly recall with no amount of fondness the miasma of configuration files in Windows 3.x: CONFIG.SYS, AUTOEXEC.BAT, WIN.INI, SYSTEM.INI, and so on. On a system with many applications and drivers installed, these files could grow quite large, were relatively difficult to work with, and weren't very fast for the operating system to access.

Starting with Windows NT 3.1 and followed by Windows 95, Microsoft did away with these files (they're still present, but only for backward compatibility) and replaced them with a single point in which all the configuration information about the system could be stored: the Registry.

There are a number of benefits that the Registry brings to the Windows family of operating systems, including the following:

In this chapter you learn about the Registry, how it works, how to edit it directly with the Registry Editor, and how to back it up and restore it. You also learn some of the important Registry keys that you might need to modify from time to time. You'll even learn about some hot "hacks" that you can do in the Registry!

Understanding the Registry

The Windows 98 Registry contains all of the configuration information about a Windows 98 system and its applications (at least those applications that are Windows 9x-compliant). All the information for the Registry is stored in two main files, SYSTEM.DAT and USER.DAT, and one optional file (if you are configured to use System Policies), CONFIG.POL or POLICY.POL.

SYSTEM.DAT and USER.DAT both reside in your \WINDOWS directory unless User Profiles are enabled, in which case there will be multiple copies of USER.DAT, one for each user that has a profile on the system. The user-specific copies of USER.DAT are stored in \WINDOWS\Profiles\username where username is the logon name used to log on to Windows and access individual User Profiles. If User Profiles are being stored on a network server, then USER.DAT resides in the user's home directory or in some other server directory that you've configured for this purpose.


Is it Safe to Modify the Registry Directly?


In just about any book that makes reference to making changes to the Registry, you will find dire warnings about the terrible things that can happen if you make a mistake. Those warnings are all true: Inappropriate changes to the Registry can make Windows 98 unstable or unable to boot, or cause other negative impacts.
However, modifying the Registry isn't really very difficult, and as long as you're careful with the changes you make, you will find that there are a lot of profitable things you can do with the Registry, and will rarely have problems. While you should treat the Registry with respect, you don't have to be paranoid about working with it.


The SYSTEM.DAT file contains all of the configuration information for the computer on which it is located. USER.DAT contains all user-specific information, such as desktop settings, application preferences, and user-specific Control Panel settings.

When you open the Registry Editor (REGEDIT.EXE), you see two main branches (called root keys) and four "shadow" (or alias) branches (see Figure 10.1). The two root keys are described here:

In addition to these two main branches, there are four alias branches that appear as main branches, but are really reflections of lower-level Registry keys in one of the two main branches:

Figure 10.1

Opening the Registry Editor reveals the main branches of the Registry.



NOTE: Alias branches exist in the Registry to make it easier to locate specific information within the main branches. For instance, if an application wants to store user-specific data, it doesn't have to figure out which User Profile is active, and how it is stored in HKEY_USERS. Instead, it can store its data in HKEY_
CURRENT_USER and Windows 98 automatically takes care of placing the data in the correct user-specific subkey of HKEY_USERS. The same goes for HKEY_
LOCAL_MACHINE and HKEY_CURRENT_CONFIG; applications don't have to determine which Hardware Profile is active--for that matter, neither do you when you use the Registry Editor!


If you use the Registry Editor to navigate down a few levels in one of the branches, you will eventually select a folder where the right pane displays data. The left pane displays the Registry keys, which are specific locations within the Registry. The right pane displays values, which are different values stored in a key. A single Registry key can contain many values. Figure 10.2 illustrates this.

Keys are specified using their complete path, with backslashes to denote different key levels. For example, in Figure 10.2 the key HKEY_LOCAL_MACHINE\Config\001\Display\
Settings is selected. In the right pane you can see a number of values, such as BitsPerPixel and DesktopPos.

Figure 10.2

Navigating the Registry reveals keys and values.

When values are created, they are created as a certain type. Under Windows 98, values can contain three types of data:


NOTE: Each key contains one value called the default value. It usually doesn't store any data, and its presence is for compatibility with the old Windows 3.1 Registry (there was a rudimentary Registry in Windows 3.1, believe it or not). The default value (called simply [Default]), if it contains data, contains string data.


Understanding the Main Registry Branches

As you've already seen, there are two main branches of keys in the Registry, and four alias branches that are actually mirrors of data in one of the two main branches. In this section, you'll learn, broadly, what each of the two main branches contains.

HKEY_LOCAL_MACHINE

The HKEY_LOCAL_MACHINE root key stores settings for the local computer itself. Examples include hardware devices, device drivers installed, current hardware configuration data, and uninstall information. HKEY_LOCAL_MACHINE does not store user-specific data.

There are seven main keys in the HKEY_LOCAL_MACHINE root key, described in the following sections.

Config

The Config key contains information about Hardware Profiles on the system (See Chapter 9, "Hardware Profiles" for more information). For each available Hardware Profile on the system, there is a subkey named with a number (such as 0001, 0002, and so forth). Within each of the numbered profiles is a subkey called Enum, which contains all of the entries for hardware devices that are active when that profile is being used by the computer.

You can decode what each numbered Hardware Profile is named by examining the key HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\IDConfigDB. Here you will find values that show the names and numbers of each Hardware Profile on the system.

Enum

The Enum subkey under HKEY_LOCAL_MACHINE holds all of the device driver information for the computer. The information in this key is not dependent on which Hardware Profile is active; every possible device ever installed on the system will be listed in this subkey.

Within Enum are a number of subkeys, each one corresponding to a different type of hardware device. Figure 10.3 illustrates these subkeys.

Figure 10.3

Subkeys of HKEY_
LOCAL_MACHINE\
Enum correspond to different device types.

The main types of information stored within Enum will depend on the configuration of the computer. For instance, a system with an EISA bus will have an EISA subkey. On a standard ISA/PCI system, the following are standard subkeys within Enum:

Hardware

Contrary to what you would expect, the Hardware subkey doesn't hold much information, mostly just descriptions of the processor and COM port mappings.

Network

Within the Network subkey is a single key called Logon. This key's values are updated each time a user logs on to the computer, and contains user-specific logon information. You will find values here for the username, network provider, and System Policy handler.

Security

The Security key holds information for any security providers being used by the computer. You can also find information about any users that are logged on to the Windows 98 system using a peer-to-peer network connection, as well as information about shared devices that are accessible through a network connection.

Software

One of the more interesting keys in HKEY_LOCAL_MACHINE, the Software key holds data stored by software installed on the computer. The subkeys present depend on which applications are installed, and what they choose to store here. Figure 10.4 shows a sample Software key.

Figure 10.4

A sample HKEY_
LOCAL_MACHINE\
Software key.

As you can see in Figure 10.4, most keys correspond to a software manufacturer. Within a particular manufacturer's key are subkeys, usually one for each of the installed applications.
In addition to the company-specific keys, you will also find some other keys of interest:

System

Under the HKEY_LOCAL_MACHINE\System key you will find a CurrentControlSet key, which is the complete set of information that Windows 98 needs to boot. The two main subkeys of CurrentControlSet, Control and System, are described in the following list:.

HKEY_USERS

Under HKEY_USERS you will find one key for each user of the computer, plus one other key called .Default, which is a default user. User-based subkeys are named for the logon name that the user uses. Within each user key, you find a number of subkeys, detailed in the following subsections.

AppEvents

AppEvents defines the possible events to which sounds can be associated, within Windows itself and for any applications that can also make use of sound events (such as Microsoft Office). There are two main subkeys: EventLabels and Schemes. EventLabels holds a description of each possible event, while Schemes holds scheme information for the sounds chosen, as well as references to the actual .WAV files that are played for each event. Within each event listed in Schemes\Apps are two keys: .Default and .Current, which define the sounds played for the default scheme and the currently selected scheme.

Control Panel

User-specific Control Panel settings are stored in this key. Within Control Panel, you'll find one key for each different Control Panel that holds user-specific information, as follows:

InstallLocationsMRU

This key holds the most recently used (MRU) installation locations for Windows 98. There are several values, lettered starting from A. There is a also a value called MRUList that holds the order in which those different installation locations should be tried when adding a driver or installing other Windows 98 software.

Keyboard Layout

This set of keys defines the keyboard layout for Windows 98.

Network

This key holds the Windows 98 persistent (and current) network connections, most notably mapped network drives. Each persistent mapped drive is stored in HKEY_USER\Network\
Persistent, and there are several subkeys: Provider Name for the network client used to access the network resources, RemotePath for the UNC of the mapped resource, and UserName for the username used to attach to the remote resource. Located in HKEY_USER\Network\
Recent are similar subkeys for accessed (but not mapped) network drives.

RemoteAccess

In HKEY_USERS\RemoteAccess you will find definition information for any dial-up networking settings stored for the users, including their provider names, any IP settings, and their user names. These entries correspond to the entries found in the Dial Up Networking folder.

Software

The Software key in HKEY_USERS holds user-specific information for the software on the system. Its structure is similar to HKEY_LOCAL_MACHINE\Software, in that there is a key for each software manufacturer, with subkeys for their applications.

Using Registry Editor

The Registry Editor is installed on every Windows 98 system in the \Windows directory, and is named REGEDIT.EXE. By default, there is no program shortcut created in the Start menu for the Registry Editor, so most people start it by using the Run command in the Start menu and then typing REGEDIT.

The Registry Editor's display is divided into two panes. The left pane shows the organization of the Registry. If you are running Registry Editor on a local computer, you see My Computer at the top of the organization. If you're administering a remote computer, you see that computer's network name at the top. Within My Computer are the six main root keys of the Registry: the two main root keys and the four alias root keys, as described previously. As is probably obvious, you click on the plus symbols next to keys to open them and on any minus symbols to close them.

The right pane shows any values attached to the key selected in the left pane. Each value has both a value name and value data.

Most people navigate Registry Editor using the pointing device. However, there are also some keyboard shortcuts that will save you time if you frequently use Registry Editor, as detailed in the following table:

Key Action
Keypad + Expands the selected key
Keypad - Collapses the selected key
Keypad * Expands the selected key, and all expandable keys within it
Up arrow Moves up one key
Down arrow Moves down one key
Right arrow Expands the current key if it's collapsed, otherwise moves to its first subkey
Left arrow Collapses the current key if it's expanded, otherwise moves to its parent key
Home Moves to the top key (usually My Computer)
End Moves to the last expanded key (does not expand any keys)
Page Up Moves up one screen
Page Down Moves down one screen
Tab Switches between the right and left panes

In the right pane, each value appears with one of two icons: one, with the letters AB on it, indicates a string value is being stored, and one, with a set of 1s and 0s, indicates that binary or DWORD data is stored there.

Searching the Registry

You can search through the entire Registry using Registry Editor, looking for keys, value names, or string value data that match your search criteria. Use the Edit, Find command to access the Find dialog box shown in Figure 10.5.

Figure 10.5

The Find dialog box lets you rapidly search the entire Registry for information.

After typing your search text, use the Keys, Values, and Data checkboxes to determine what will be searched. You can also select Match Whole String Only to avoid searching for partial matches.

After finding the first key or value that matches your search criteria, use the Edit, Find Next command to find the next match, or press the F3 key to also continue the search.

There is an abbreviated way to find keys quickly, assuming they are already expanded and don't contain spaces: With the left pane active in Registry Editor, simply start typing the name of the key. You will continue jumping to matching keys as you type more of the key name that you want.


NOTE: Searching for keys can sometimes take a while. Also, remember that four of the main root keys are aliases, so you might get multiple hits for a particular search phrase, each hit possibly representing the same actual data in the Registry.


Editing a Value's Data'

After finding the key you're searching for and selecting one of the values in the right pane, you can edit the value data. There are three ways to edit a value's data: Double-click on the value's name, select a value and choose Modify from the Edit menu, or right-click on a value and choose Modify from the pop-up menu. Depending on the type of data being stored in that value, you then see one of three different dialog boxes, presenting string, DWORD, or binary data, as shown in Figures 10.6, 10.7, and 10.8, respectively.


NOTE: You cannot change the type of data stored by a value. Instead, you must remove the value and then re-create it (using the same name) for the type of data you want it to contain.


Figure 10.6

To edit string data, simply type the new data in the Value Data field.

Figure 10.7

To edit DWORD data, enter the data in the field and choose Hexadecimal or Decimal, depending on how you entered the value.


Figure 10.8

To edit binary data, start typing the hexadecimal values for each byte in the Value Data area.

Adding Keys and Values

To create a new key in Registry Editor, first select the key that will contain the new key. Then, choose Edit, New, Key to create the new key. A new key is created with the name New Key #1; you can start typing immediately to assign a different name to the key.

To create a new value, first select the key that will hold the value. Then use one of the three other commands you see when you open the Edit, New menu: String Value, Binary Value, or DWORD Value. Select the appropriate command based on the type of data the value will hold. The value is created with an editable name; start typing immediately to assign the value its new name. You then modify the contents of the new value just as you would do for an existing value (double-click on the value entry, for instance).

Renaming Keys and Values

The easiest way to rename a key is to right-click on it and choose Rename from the pop-up menu. You can then type the new name for the key. You can do the same for values: Simply right-click on them and choose Rename from their pop-up menus.

Deleting Keys and Values

To delete a key, simply select the key and press the Delete key. That key, as well as all keys and values within that key, are then deleted after you acknowledge a warning message box.

Similarly, you can select a value and press the Delete key to quickly delete that value.


WARNING: Deleting keys and values should be done only if you're absolutely sure that you want to remove the key or the value. Deleting keys can be particularly dan-gerous because all of its subkeys are also deleted. When in doubt, don't do it!


Importing and Exporting Registry Keys

Registry Editor provides the ability to export and import Registry keys--and even the entire Registry--to ASCII text files. This can be useful when you want to send a Registry key and its values to another user and import the Registry information into their Registry. You can also export Registry information so that you can examine it or analyze it in different ways, or even make a backup copy of the Registry information. You can also export the Registry to perform Search and Replace operations on the data: Use a text editor to perform the Search and Replace, and then import the modified Registry data from the text file.

Exported Registry keys are stored in .REG files, which can be viewed and edited with any text editor (such as WordPad or Notepad). Figure 10.8 shows an exported Registry fragment in WordPad.

To export a Registry key, first select the key you want to export and then access the Export Registry File command from the Registry menu. This brings up the Export Registry File dialog box seen in Figure 10.9.

In the Export Registry File dialog box, assign a name for the exported Registry file, and then choose whether you want to export only the current key and its subkeys (Selected Branch) or the entire Registry (All).

There are two easy ways to import an exported Registry file. The most obvious way is to start Registry Editor and then choose Import Registry File from its Registry menu. Occasionally, it is easier to simply double-click on a .REG file. Windows 98 has a file association for .REG files that corresponds with the Registry Editor, and so .REG files are automatically imported when you double-click on them. Under Windows 98 you (or the user) are warned before the key is imported, whereas in Windows 95 the key was immediately imported.


Figure 10.9

The Export Registry File dialog box.



TIP: You can import .REG files using various command-line options for REGEDIT. See the next section, "Registry Editor Command-line Parameters," for details.


The layout of the .REG files is straightforward. Each key is listed, with its full Registry pathname, in square brackets. Following each key are all of the values that the key contains, in this format:

"Valuename"=data

Data can be any of the three value types. String data is specified with surrounding quotation marks. DWORD data is specified with the format dword:00000000, with the 0s replaced with whatever value is appropriate, in hexadecimal format. Binary values are given in the form hex:00,00,00,00..., with each byte specified in hexadecimal, separated by commas. If binary data exceeds a single line in the text editor, use a backslash to continue the series of values. For instance, the following is a valid .REG entry for a large binary value:

[HKEY_USERS\.Default\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit]
"View"=hex:2c,00,00,00,00,00,00,00,01,00,00,00,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,\
  ff,ff,ff,ff,ff,ff,20,00,00,00,06,00,00,00,fa,02,00,00,2f,02,00,00,63,01,00,\
  00,dd,00,00,00,20,01,00,00,01,00,00,00



WARNING: When sending an exported .REG file to others for them to import, make sure that you only send them the keys that they need. For example, you wouldn't generally want to send them any keys that configure their hardware, unless you know exactly what you're doing and you intend to do that. If you're sending them more than a single key, it's a good idea to double-check the .REG file with a text editor to make sure that they're only going to get the keys that you want them to get. Importing inappropriate keys can have disastrous consequences for the recipient of a .REG file!


Registry Editor Command-line Parameters

You can start Registry Editor with one of several different sets of command-line parameters. These can be useful in batch files or when you need to perform a set of actions with Registry Editor and need to automate them. These Registry Editor command-line parameters also work if you start the system in MS-DOS mode, and can be used for maintenance activities in that mode.

The first method imports .REG files into the Registry. The syntax is as follows:

REGEDIT [/L:location_of_system.dat] [/R:location_of_user.dat] importfile1.reg importfile2.reg ...

All methods for starting Registry Editor from the command line can use the optional /L and
/R parameters to locate the SYSTEM.DAT and USER.DAT files. By default, Registry Editor finds them in the \Windows directory. After specifying those parameters, if needed, you can simply list all of the .REG files that you want to import into the Registry, each one separated by a space.

Just as you can import Registry keys from the command line, so too can you export keys from the command line. Use this syntax for exporting .REG files:

REGEDIT [/L:location_of_system.dat] [/R:location_of_user.dat] /e filename.REG Registry_Key_Name_To_Export

The final command replaces the complete contents of the Registry with the contents of a specified .REG file. Use great care with this command. The syntax is as follows:

REGEDIT [/L:location_of_system.dat] [/R:location_of_user.dat] /c filename.REG

How Can I Completely Rebuild my Registry Files? (And Why Would I Want To?)


When you add and remove keys from the Registry, Windows doesn't compact the SYSTEM.DAT and USER.DAT files--it just marks the deleted data space as being deleted. If you're using a system that has had a lot of software added and removed from it, the Registry file can become quite large, much of it actually consisting of deleted data (you can't see the deleted data in REGEDIT, but it's probably there.) To compact the Registry in this case, start the system in MS-DOS mode (hold down the left Ctrl key while Windows 98 boots and choose Command Prompt Only from the Windows Startup menu). Then, use the following command:

REGEDIT /L:C:\WINDOWS\SYSTEM.DAT /R:\WINDOWS\USER.DAT /e C:\FULLREG.REG \

(If you are using User Profiles, make sure to use the appropriate User Profile path for the /R parameter).
After exporting the Registry in this fashion, clear the attributes on the USER.DAT and SYSTEM.DAT files with ATTRIB filename.DAT -r -h -s. Then, copy USER.DAT and SYSTEM.DAT to a backup location and erase the originals in \WINDOWS. Use the following command to rebuild the Registry using the export file you just created:

REGEDIT /L:C:\WINDOWS\SYSTEM.DAT /R:\WINDOWS\USER.DAT /c C:\FULLREG.REG

To keep things nice and tidy, remember to reset the attributes on the Registry's .DAT files with the command ATTRIB filename.DAT +r +h +s.


Backing Up and Restoring the Registry

Because the Registry is made up of two normal files, SYSTEM.DAT and USER.DAT, it is easy to back up the Registry. One way to do this is to create a batch file that runs as part of your Startup folder. In the batch file, you can use XCOPY to backup the Registry files to a new location. Keep in mind that SYSTEM.DAT and USER.DAT are normally flagged as hidden, read-only when you do this, however.

Using Batch Files to Back Up the Registry

If you really want to get fancy and make multiple backup copies, you can store them in several locations, and the batch file can move the files from location to location. Here's an example of a set of commands that will keep the three most current Registry sets in three directories, called \RegBack1, \RegBack2, and \RegBack3 (you must create the directories before running this batch file):

REM Begin Registry Backup Batch File
ERASE C:\REGBACK3\*.DAT
MOVE C:\REGBACK2\*.* C:\REGBACK3
MOVE C:\REGBACK1\*.* C:\REGBACK2
ATTRIB C:\WINDOWS\USER.DAT -r -h
ATTRIB C:\WINDOWS\SYSTEM.DAT -r -h
XCOPY C:\WINDOWS\USER.DAT C:\REGBACK1
XCOPY C:\WINDOWS\SYSTEM.DAT C:\REGBACK1
ATTRIB C:\WINDOWS\USER.DAT +r +h
ATTRIB C:\WINDOWS\SYSTEM.DAT +r +h

To restore the Registry from a backup, simply copy SYSTEM.DAT and USER.DAT back to their appropriate places (C:\Windows and C:\Windows\Profiles\username if User Profiles are active) from whatever backup copy you have. Remember to clear the hidden and read-only file attribute bits on the real ones before you do this, and then restart the system immediately.

Using CFGBACK to Back Up the Registry

A more elegant way to back up the Registry is to use a Windows 98 Resource Kit utility called CFGBACK. The CFGBACK utility can store up to nine versions of your Registry files, letting you restore any of the nine at any time.

To run CFGBACK, you'll simply need to copy the CFGBACK.EXE file to your \Windows directory. If you want to, you can place a shortcut for the program on your Start menu or desktop.

When you run CFGBACK, you see the screen shown in Figure 10.10. Simply type a name for the backup in the Selected Backup Name field and click the Backup button. CFGBACK takes a few minutes to back up the Registry on most systems.

Figure 10.10

CFGBACK makes quick work of backing up and restoring the Registry.

To restore a previous version of your Registry, select the one you want to restore in the List of Previous Backups list and click the Restore button. It doesn't get much easier than this!

CFGBACK stores its backups of the Registry in the \Windows directory, with the names being REGBACK1.RBK, REGBACK2.RBK, and so forth. One nice benefit of CFGBACK is that it compresses its backups, so each backup file doesn't take up nearly as much disk space as the USER.DAT and SYSTEM.DAT files.


NOTE: CFGBACK is installed from the Resource Kit CD-ROM as one of the Resource Kit's Registry Tools.


Remotely Administering the Registry

The Windows 9x Registry can be remotely administered across a network. A program that comes with Windows 98, called Microsoft Remote Registry, enables this feature.

In order to remotely administer a computer's Registry, you must perform the following steps on both the computer to be administered, and the computer from where you will be administering the remote Registry:

1. Enable User-level access control. Open the Network Control Panel's properties and move to the Access Control tab. Select the User-Level Access Control option button.
2. Using the Configuration tab of the Network Control Panel, click the Add button. You see the Network Configuration Type dialog box.
3. Click on Service in the Network Configuration Type dialog box and click the Add button.
4. Click the Have Disk button.
5. Use the Browse dialog box to select the file REGSRV.INF. It should be located in the \TOOLS\RESKIT\NETADMIN\REMOTEREG directory on the Windows 98
CD-ROM.
6. Complete the addition of the new service, and restart the computer when prompted.

After completing the preceding steps on both computers, you can then edit the remote computer's Registry using the Registry Editor, provided both computers share a common network protocol. Open the Registry menu and choose Connect Network Registry, and then type the remote computer's name in the dialog box that appears.


TIP: If you want to store the Remote Registry Service files on a network server for easy installation on client computers, you'll need to have these three files: REGSRV.EXE, REGSRV.INF, and WINREG.DLL.


Specific Registry Tips and Tricks

Because you've read the preceding information in this chapter, you now understand what the Registry is, what it does, how it works, and how to manage it. In the remaining sections of this chapter, you learn about specific things you can do to the Registry in different circumstances. Each heading lists the action you can perform, so you can rapidly find it by searching this book's Table of Contents.

Managing File Associations

File association information is stored in the HKEY_CLASSES_ROOT root key, shown open in Figure 10.11. Every file extension registered on the system can be found in one of its subkeys.


Figure 10.11

File associations are maintained in HKEY_CLASSES_ROOT.



NOTE: HKEY_CLASSES_ROOT is an alias of HKEY_LOCAL_MACHINE\Software\
Classes. You can make changes to either location, whichever is more convenient for you.


The HKEY_CLASSES_ROOT root key holds a listing of file association keys (all beginning with a period, and showing the actual file association) as well as keys that tell Windows how to behave with files of that extension. For example, examine the entries for .BAT files. Figure 10.12 shows the value settings for files of .BAT type.

Figure 10.12

A .BAT file simply holds a [Default] value with the name of the file type.

As you can see in Figure 10.12, .BAT files just have a [Default] value with the string "batfile" as its data. Alone, this information isn't useful and doesn't tell you what Windows will do with this file when manipulated from Explorer. However, if you scroll further down the HKEY_CLASSES_ROOT key, you will find another key called HKEY_CLASSES_ROOT\
batfile. It is in this key that you can find the information for how Windows 98 works with .BAT files, as shown in Figure 10.13.

Figure 10.13

The Class Definition Subkey for batfile.

The HKEY_CLASSES_ROOT\batfile key is known as a class definition subkey. It defines the Explorer behavior for files of that type. As you can see in Figure 10.13, there are several types of subkeys for the class definition subkey.

The [Default] entry contains the description for the file type. This name shows on the Properties dialog box for files of this type. The DefaultIcon subkey defines the location for the default icon for files of this type.

The shell subkey holds information for how Windows 98 should perform certain user actions on the file. There is one subkey for each possible action, with this batfile example showing commands for Edit, Print, and Open. In each command there is another subkey called command. This command subkey contains the command that will be executed in its [Default] value. For instance, examine Figure 10.14, which shows the Edit command's command subkey.

As you can see, if you choose Edit from the pop-up menu for a .BAT file, you are actually executing the command NOTEPAD followed by the %1 parameter (which is the name of the file).

Figure 10.14

A batfile's Edit command in Explorer.

Any file extension or class definition key that contains a ShellNew subkey will appear when you right-click in a folder in Windows Explorer and choose the New submenu, as shown in Figure 10.15.

Figure 10.15

The ShellNew subkeys are responsible for a file type appearing when you open the New menu in Explorer.


Why Class Definition Subkeys?



Class definition subkeys are used to make the Registry storage of different files more efficient. For example, you can have many different file extensions for a single type of file (.HTM and .HTML are both valid file types for HTML files). By storing only a class definition subkey name within each file extension, and then placing all of the information for how to handle that type of file within the class definition subkey itself, a single set of information can be made to work with multiple file extensions.


Changing File Type Icons

To change the icon displayed for a file using the Registry, open the key HKEY_CLASSES_ROOT, and then find the extension that the file uses (for example, .WAV). Select that key, and look at the data for the [Default] value. It will specify the class definition subkey name that handles the file. (For .WAV files it is SoundRec).

Then, locate the class definition key (SoundRec in this example) within HKEY_CLASSES_
ROOT and open it. You should see a subkey called DefaultIcon. The DefaultIcon subkey only has a [Default] value, which contains a pointer to an icon file. Change the value of [Default] so that it instead points to a file that contains icons, such as a .ICO file. You can also indicate a .DLL file that contains icons. The two syntaxes for the [Default] value are as follows:

[Default]="pathname\filename.ico,0"
[Default]="pathname\dllfile.dll,-xx"

that xx is the resource identifier for the icon within the .DLL file.

Add Actions to Pop-up Menus

You can easily add new actions to Explorer's pop-up menus for different file types. One reason for doing this would be to open a particular type of file with more than one program from Explorer. For example, you might want to open some .TXT files with Windows Notepad, and others with a programmer's text editor, like Brief or SlickEdit. Follow these steps (substituting your own chosen extension and programs as needed) to see how this works:

1. Open the Registry Editor and locate the .TXT file type in HKEY_CLASSES_ROOT.
2. Find the class definition subkey name (in this case, txtfile) and then locate that entry in HKEY_CLASSES_ROOT.
3. Open the subkey txtfile\shell.
4. Add a new subkey to txtfile\shell. This new subkey will be the command that appears when you right-click on any .TXT files. In this example, use the key name Open with SlickEdit.
5. To that new subkey, add another subkey called command. In this case, you would create the key txtfile\shell\Open with SlickEdit\command.
6. Set the [Default] value of the command key to be a string value, containing the program name followed by %1 to denote the actual filename. In this case, e:\util\slickdos\s.exe %1 is specified.

You should close the Registry Editor after making these changes, although it is not necessary; the changes are effective as soon as you complete step 6 in the preceding instructions. Figure 10.16 shows the new pop-up menu command.

Figure 10.16

The added command on the pop-up menu for a .TXT file.



TIP: In Figure 10.16 you can see that both the Open command and the Open with SlickEdit command share the same hotkey. You can define alternate hotkeys for pop-up menu commands. Select the key that contains the actual command (in this example, the key \txtfile\shell\Open with SlickEdit) and set its [Default] value to equal the command name, but insert an ampersand in front of the letter that you want to act as the hotkey. For example, to use the w in with as the hotkey, you would specify the string Open & with SlickEdit as the [Default] string value.


Adding New Sound Events

You use the Sounds Control Panel to control what sounds happen with which application events. You can use the Registry Editor to create new sound events, too. For example, say you want to assign special sounds for when Registry Editor itself is opened and closed. Follow these steps to do this:

1. Using Registry Editor, navigate to the HKEY_CURRENT_USER\AppEvents\Schemes\Apps key.
2. Add a new subkey with the name of the program. In this case, create a subkey called regedit.
3. Within the regedit key, create a key for the common application events such as Open and Close.
4. Set the [Default] value of the regedit key to be a friendly name, such as Registry Editor.
5. Open the Sounds Control Panel. If you scroll down to the bottom, you'll now see Registry Editor listed, along with the Open and Close events (if those are the events you defined in step 3).
6. Assign .WAV sound files to the two events.

After doing this, try opening and closing Registry Editor. If everything was done correctly, you'll hear the sounds you selected when you open and close it.

You can use the following Windows event names for each application:

Event Name Description
Open An application starts
Close An application closes normally
Maximize An application's window is maximized
Minimize An application's window is minimized
MenuCommand A menu command is chosen in the application
MenuPopup A pop-up menu command is chosen in the application
SystemAsterisk An "asterisk" system message is generated from the application
SystemExclamation An "exclamation" system message is generated from the application
SystemQuestion A "question mark" system message is generated from the application

Changing Desktop Icons

Some of the objects on the Windows 98 desktop don't make it easy for you to change their icons. With the Registry, however, you can change just about anything, including the names and icons for any of the standard desktop objects. To do so, follow these steps:

1. Using Registry Editor, open the key \HKEY_CLASSES_ROOT\CLSID.
2. Find the numeric subkey corresponding to the object you want to change (see Table 10.1)
3. Open the key you located in step 2, and you will find a DefaultIcon subkey.
4. Change the DefaultIcon subkey's [Default] entry to point to a different .ICO file.

Table 10.1 Standard Desktop Icon CLSIDs

Name CLSID
Briefcase {85BBD920-42A0-1069-A2E4-08002B30309D}
Control Panel {21EC2020-3AEA-1069-A2DD-08002B30309D}
Dial-Up Networking folder {992CFFA0-F557-101A-88EC-00DD010CCC48}
Inbox {00020D75-0000-0000-C000-000000000046}
My Computer {20D04F#0-3AEA-1069-A2D8-08002B30309D}
Network Neighborhood {208D2C60-3AEA-1069-A2D7-08002B30309D}
Printers {2227A280-3AEA-1069-A2DE-08002B30309D}
Recycle Bin {645FF040-5081-101B-9F08-00AA002F954E}
Internet {FBF23B42-E3F0-101B-8488-00AA003E56F8}

TIP: You can usually locate CLSID numbers yourself by searching the Registry for the name of the object. For instance, searching the Registry for My Documents helps you locate the CLSID of {450D8FBA-AD25-11D0-98A8-0800361B1103}.


Changing Windows Folder Locations

Windows maintains a number of default folder locations that you can't easily move. For example, you cannot relocate the \Windows\Recent folder or the \Windows\Fonts folder without making use of the Registry Editor.

To change the locations for Windows 98 folders, locate the key HKEY_CURRENT_USER\
Software\Microsoft\Windows\CurrentVersion\Explorer\ShellFolders. The values in this key define where Windows 98 looks for different types of information, and depends on whether or not User Profiles are being used. For example, Figure 10.17 shows this key for user Bruce when User Profiles are being used.

The value names (such as Startup, Fonts, Start Menu) are self-explanatory and map to the folder functions. Before changing one of these values, however, you should make sure that the new destination folder is in place and that it contains the necessary files that Windows will expect for that type of folder.


NOTE: You must restart Windows in order for the new folder locations to take effect.


Figure 10.17

You can use this key to move Windows default folder locations.

Expanding the Icon Cache

Windows Explorer caches displayed icons in a file named C:\Windows\ShellIconCache. The file has no extension and is hidden by default. Windows 98 stores up to 512 icons in the cache, which it uses to more quickly display icons on the desktop or in Windows Explorer. When the cache fills, it is re-created from scratch, using the icons stored in the actual source files. You can expand the number of icons stored in this file, possibly eliminating the need for Windows to re-create it when it fills.

Using Registry Editor, navigate to the key \HKEY_LOCAL_MACHINE\Software\Microsoft\
Windows\CurrentVersion\Explorer, and add a new value named Max Cached Icons holding a string value. The string value should be set to a number representing how many icons will be stored, such as 2000.

Changing the Menu Delay

When you move your mouse to a submenu, such as the Programs menu inside the Start menu, there is a pause before the submenu opens. The pause makes it easier for novices to work with Windows 98, but more advanced users often find the delay annoying. You can change the duration of the delay with a simple Registry change.

Using Registry Editor, navigate to the key HKEY_CURRENT_USER\Control Panel\
Desktop. In that key, look for a value called MenuShowDelay. If it is not present, add it as a string value. The default string value (even if the value isn't present) is 400. You can reduce this to a much smaller number, even all the way to 0 if you like. that Windows must be restarted for this change to take effect.


TIP: You'll find that setting the MenuShowDelay setting too low makes Windows menus frustrating to use, even for experienced people. You'll want to experiment with the value, but you'll probably find that a delay of 200-300 is best overall.


Removing Inbox from the Desktop

You can remove the Inbox from the Windows desktop. Locate the key HKEY_LOCAL_
MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace. In this key you will find several subkeys, each of which is named with the CSLID of the desktop objects. Locate the subkey named {00020D75-0000-0000-C000-00000000046} and remove the key.

Viewing Bitmap Contents as Icons

If you maintain a lot of .BMP files on your system, you can set Windows 98 to display the contents of the .BMP files as their icons. To do this, find the key HKEY_CLASSES_ROOT\
Paint.Picture\DefaultIcon and set its [Default] value to "%1". After restarting Windows, the bitmap file contents are displayed as their icons, as shown in Figure 10.18.

Figure 10.18

With the proper Registry change, you can view BMP contents as icons.

Change How Short Filenames are Generated

Windows 98 lets you use names for your files that are up to 254 characters long. As you probably know, however, Windows always stores a short version of the long filename for compatibility with DOS and older Windows programs. These short versions follow the 8.3 naming convention. When Windows generates a short filename for this purpose, it adds a tilde (~) in the seventh position of the eight-character filename, and then adds a number as the eighth character. For example, two files called "My Letter to Mom.DOC" and "My Letter to Dad.DOC" will have their short names set to "MYLETT~1.DOC" and "MYLETT~2.DOC". Windows adds the tilde and the number whether or not there are any conflicts within that directory.

As an experienced user or support person, you've probably noticed how annoying it is to type the tilde character when working with short filenames at a command prompt. Fortunately, with a simple Registry change, you can alter this behavior somewhat. Locate the key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem and create a new binary value called NameNumericTail. Set the data of the new value to 0.

After you make this change, the tilde will be eliminated from the short version of filenames. However, if you create new files in the same directory that would conflict with an existing short filename, the tilde, along with a number, will return for those conflicting files.

Assigning a Viewer to Unknown File Types

As a computer professional you often have to view the contents of files that don't have a registered file association. Perhaps you want to view the contents of a binary file in a text editor for some reason, or you want to view a text file that uses a non-standard extension. Unfortunately, Windows doesn't offer an Open command for files that don't have a registered file type.

You can use the Registry to make it easier to open files with an unknown type with whatever program you want to use, such as Notepad or your favorite programmer's editor. To do this, locate the key HKEY_CLASSES_ROOT\Unknown\Shell. Add a new subkey, whose name is the command you want to appear on the pop-up menu for unknown files. For this example, say you want to use SlickEdit to view such files, so create a subkey called Slick Edit. In the new subkey, set the data for the [Default] string value to be the command line that needs to be executed. In this example, you would set [Default] to be "C:\SlickEdit\S.EXE %1". Voil�! After making this change, you can right-click on any unknown file types and you'll see the command you created, letting you quickly view or edit such files.

Setting Double-Click Hot Zones

If you've observed beginning users with Windows, you've probably seen them make a frequent mistake: They let the mouse pointer move ever so slightly while performing a double-click. Because the pointer was moving, Windows interprets their action as a really small move instead of a double-click. You can change the sensitivity for this interpretation.

Locate the key HKEY_CURRENT_USER\Control Panel\Desktop. Create two new string values called DoubleClickHeight and DoubleClickWidth. Set the data for the values to string numbers, where the numbers you enter are given in pixels. You'll want to experiment with these settings, but start with setting each one to 5 or 10. Restart Windows to check the setting.

Disabling Window Animation

Windows animates the openings and closings of windows, making it easier for novices to see what their computer is doing. This animation takes a little bit of time, however, and can slow down more advanced users. You can make Windows seem livelier if you disable these animations.

Locate the key HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics. Create a new string value called MinAnimate, and set its value to 0 (a 1 means to enable animations). Minimize and maximize a window to remember what it looks like, and then restart Windows and do the same thing again. You'll notice that windows open and close faster with the animations off.

Changing User Information

An individual's name and company are provided during a Windows installation. You can see this information if you open the System Control Panel and look at the first tab. Using the Registry Editor, you can easily change these values if needed, such as when a new person is hired at your company and inherits a computer used by another person.

Locate the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Current-Version. In this key, you will see two values: RegisteredOrganization and RegisteredOwner. Simply change the data for those two values to whatever information you want to use.

Conclusion

In this chapter you learned about the Windows Registry--what it is, how it's structured, how it works, and how to manipulate it. You learned how to use Registry Editor, the main tool for working with the Registry. You also learned about backing up and restoring the Registry, and about doing remote administration with the Registry.

This chapter concludes the section on Configuring Windows 98. In this section, you learned everything you should need to know about the Registry, the Control Panel, User Profiles, Hardware Profiles, System Policies, and how these different features work together to let you configure and manage Windows 98 systems.

Part III of this book, "Windows 98 Operations," details Windows 98's architecture, followed by a number of chapters about working with and supporting Windows 98.


Previous chapterNext chapterContents

Copyright, Macmillan Computer Publishing. All rights reserved.