The Registry stores data in a tree with a hierarchical structure. The tool that allows you to view, edit, and manage the Registry is called the Registry Editor, shown in Figure 10-1. The main screen of the Registry Editor displays the structured tree inwhat else?a tree view control. The data elements shown in Figure 10-1 are known as keys (HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, and so on). Each key can contain children, which are known as subkeys. (In Figure 10-1, Display is a subkey of HKEY_CURRENT_CONFIG, while Fonts and Settings are subkeys of the Display key.) Data entries are called values (BitsPerPixel, DPILogicalX, and so on). Each value consists of a value name and its associated data (if any).
Figure 10-1.
Keys don't necessarily have values associated with them. Sometimes, an application simply needs to know that a key exists; at other times, the application might need to associate many values with a specific key (as shown in Figure 10-1). A key can have any number of values associated with it, and the values can be in any form.
Just like dogs, keys have names. A key name consists of one or more printable ANSI characters (values in the range 32 through 127) and cannot include spaces, backslashes, or wildcard characters (* and ?). Key names beginning with a period (.) are reserved. This means that you can name both your dog and your key Spot if you so desire. These names are not localized into other languages, although values associated with the keys can be localized. Subkeys also have names. The name of a subkey must be unique with respect to the key immediately above it in the hierarchy.
The Registry supports several different data types for values, described in Table 10-1 on the following page. Your application can use any of these data types, depending on what you want to store.
Data Type | Description |
REG_BINARY | Binary data in any form. |
REG_DWORD | A 32-bit number. |
REG_DWORD_BIG_ENDIAN | A 32-bit number in big-endian format (in which the most significant byte of a word is the low-order byte). |
REG_DWORD_LITTLE_ENDIAN | A 32-bit number in little-endian format (same as REG_DWORD). Little-endian format (in which the most significant byte of a word is the high-order byte) is the most common format for computers running Windows NT. |
REG_EXPAND_SZ | A null-terminated string containing unexpanded references to environment variables (for example, %PATH%). This value is a Unicode string or an ANSI string, depending on whether you use the Unicode functions or the ANSI functions. The Registry always stores strings internally as Unicode strings. |
REG_LINK | A Unicode symbolic link. |
REG_MULTI_SZ | An array of null-terminated strings, terminated by two null characters. |
REG_NONE | No defined value type. |
REG_RESOURCE_LIST | A device-driver resource list. |
REG_SZ | A null-terminated string. This value is a Unicode string or an ANSI string, depending on whether you use the Unicode functions or the ANSI functions. |
Table 10-1. Data types for Registry values.