The System Registry

Every Windows operating system needs to keep track of information about users, hardware, and software. In Windows 3.x, this function was performed by special files called initialization (INI) files. INI files are text files that are divided into sections and keywords. Sections are delineated by square brackets, and keywords are used to set values inside each section. For example, if you wanted a program to remember the name of the last person who used it, you might establish a section called Users and a keyword called Last to track the information. The INI file entry for this information would look like this:

  [Users]
Last=John Smith 

Once the program had been properly set up, the name of the last user and any user-specified options could be stored in the INI file. With the information saved in the INI file, the program could read the INI file on startup and restore the options specified by the last user.

INI files can be used for all sorts of similar information storage. They are convenient and quick storage devices, and because they can be edited with any text editor, such as Notepad, they are extremely easy to use.

The problem with INI files is that they are inefficient. Using a text file to store a few pieces of data is fine, but mayhem can result if you need to store a large amount of data, especially if that data must be cross-referenced with other data. Text files just don't work when the situation calls for a true database.

Recognizing the inherent problems with INI files, Microsoft has developed the Windows 95 Registry. The Registry is a unified database for storing system and application configuration information in a hierarchical format. The Registry can be compared to INI files. For example, the bracketed sections in INI files are similar to Registry keys, and the keyword entries are similar to Registry values. The Registry contains information ranging from the name of the last user to the ActiveX components available on your computer.

The Registry has a special role to play in Automation. Software components, such as servers and ActiveX controls, have entries in the Registry that describe them. In particular, every component stores its class ID in the registry. The class ID is a unique sequence of characters that is used by the Windows operating system to identify a component. In this way, the operating system can track and maintain ActiveX components.

Class IDs are particularly important in VBScript. As mentioned earlier, VBScript uses the CLASSID attribute in the new <OBJECT></OBJECT> tags to identify the ActiveX component that is to be loaded into memory. When the browser encounters the <OBJECT></OBJECT> tags, it checks the client's Registry for the component with the specified class ID. If the component does not exist on the client machine, the browser can request a download from the server on the basis of a location specified by the web page creator. The ActiveX control will then be downloaded, and appropriate entries will be made in the Registry to identify the component the next time it is required. Because a component's class ID is unique, no confusion exists about which component is needed by the web page.

The Registry is simply a database, so you can actually look at its contents. Windows 95 provides a utility called the Registry Editor (REGEDIT.EXE) for viewing and editing the Registry. REGEDIT opens the Registry and allows you to browse the keys and values. You can even search for a key. Figure 4-2 shows the Registry Editor window, which is composed of two panes. The left pane displays the keys, and the right pane displays the value entries of the selected key.

Figure 4-2.

The Registry as displayed by REGEDIT.

CAUTION: If you examine your Registry by using the utility REGEDIT.EXE, do not make any changes to the information you find. Changing the information in the Registry can cause serious problems in your operating system.

By browsing the Registry, you can find class IDs for ActiveX components and use these sequences of characters in your web pages. Class IDs can be found under HKEY_LOCAL_MACHINE\SOFTWARE\Classes\. In this area, search for the name of the control you are interested in. For example, if you wanted to use the Gauge control and it is registered on your computer, you could search for the word gauge. In this case, you would find an entry for the Gauge control that has the key {7A080CC5-26E2-101B-AEBD-04021C009402}, which is the class ID. Figure 4-3 shows the class ID for the Gauge control in the system Registry.

Figure 4-3.

The class ID for the Gauge control in the system Registry.

This sequence of characters can be used directly in the <OBJECT></OBJECT> tags. An example is shown here:

  <OBJECT>
    CLASSID="clsid:7A080CC5-26E2-101B-AEBD-04021C009402"
    ID="/Gauge1/"
</OBJECT> 

NOTE: Be sure to remove the curly braces from the Registry's class ID before you insert it into the <OBJECT></OBJECT> tags.

© 1996 by Scot Hillier. All rights reserved.