Introduction


The Registry is the primary repository for system, application, and user profile configuration information for the Windows operating system. It is a hierarchical database that is structured and used much like a filesystem. The operating system uses the Registry to store information as static as environment variables and as dynamic as performance data. The Registry is constantly being used by the OS and applications to read, write, and query configuration settings.

Don't Be Scared of the Registry

You have probably seen this warning or one similar to it in an article, book, or Microsoft KB article:

WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.

We think this type of warning has made some people overly cautious about modifying or even browsing the Registry. We're here to say that it doesn't have to be that way. Sure, you can muck up the Registry, just like you can muck up the operating system or just about any application if you haphazardly delete or modify things. But you are a reasonable person who won't go around making changes on a production system unless you know the impact, so let's put concerns about modifying the Registry behind us and move forward. Use the Registry as a great source of configuration information and as a tool for customizing the operating system.


Using a Graphical User Interface

Windows 2000 came with two graphical Registry editors that had different benefits. The first (regedit.exe) was more user-friendly, had better search capabilities, and was easy to work with while the other (regedt32.exe) was much more powerful. In Windows XP, most of the features of these two tools were combined into a single tool. Now, Registry Editor has the same look and feel as the user-friendly version in Windows 2000 (regedit.exe), but also incorporates some important features such as permission editing from regedt32.exe. If you run either regedit.exe or regedt32.exe, you'll bring up the same tool.

Using a Command-Line Interface

The one command-line tool we use extensively throughout this chapter is reg.exe. It comes installed by default with Windows XP. With it, you can:

  • Search the Registry

  • Add, modify, and delete Registry keys and values

  • Import, export, and compare Registry files

Using Group Policy

You can use Group Policy to manipulate the Registry using predefined Group Policy settings that correspond to Registry values or by creating a custom template that contains any keys and values you want to configure. See Recipe 9.3 for more information.

Using Downloadable Software

A graphical downloadable tool you should be familiar with is Registry Monitor (regmon.exe) from Sysinternals (http://www.sysinternals.com). With it, you can view all of the Registry activity on a system in real time. You can restrict the output to a certain key, and limit the type of activity (read, write, etc.). We cover Registry Monitor in more detail in Recipe 9.11 and Recipe 9.12.

To create Registry links, we use the regln tool as described in Recipe 9.10. You can download regln from the following location: http://www.ntinternals.net/regln/.

Using VBScript

WMI has a single class called StdRegProv that provides most of the functions you'll need to programmatically manage the Registry. Table 9-1 contains the methods available with this class. This class is a little different from most others in that it doesn't contain properties for object instances (keys, values, etc.). To obtain information about a Registry key or value, you have to use one of the methods shown in Table 9-1.

Table 9-1. StdRegProv methods

Method

Description

CheckAccess

Determines if a user has the specified permissions on a Registry key.

CreateKey

Create a key

DeleteKey

Delete a key

DeleteValue

Delete a value

EnumKey

Enumerates the subkeys of a key

EnumValues

Enumerates the values of a key

GetBinaryValue

Retrieves data from REG_BINARY value

GetDWORDValue

Retrieves data from REG_DWORD value

GetExpandedStringValue

Retrieves data from REG_EXPAND_SZ value

GetMultiStringValue

Retrieves data from REG_MULTI_SZ value

GetStringValue

Retrieves data from REG_SZ value

SetBinaryValue

Sets data for REG_BINARY value

SetDWORDValue

Sets data for REG_DWORD value

SetExpandedStringValue

Sets data for REG_EXPAND_SZ value

SetMultiStringValue

Sets data for REG_MULTI_SZ value

SetStringValue

Sets data for REG_SZ value




Windows XP Cookbook
Windows XP Cookbook (Cookbooks)
ISBN: 0596007256
EAN: 2147483647
Year: 2006
Pages: 408

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