2.1.2 Configuration Registry

The registry is a database where configuration information is stored. This database takes the place of most configuration and initialization files. Data in the registry is structured as a hierarchical tree of keys and values. The database is something like a file system, in that each key can contain both subkeys (analogous to directories) and data entries or values (analogous to files). A key will have an associated security descriptor to control access to its data. For more information about the registry, refer to the Registry overview in the Win32 online documentation.

Device drivers can use the registry to store a variety of information. In general, drivers should make use of the registry to store all data they wish to maintain across boots. In addition, drivers can access the registry to obtain information stored there by the system or by other programs or drivers. For a discussion of registry use by device drivers, refer to the Kernel-mode Drivers Design Guide.

Two trees in the registry are useful during driver installation:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

Each installed driver is required to have a key under this tree. At boot time, the system looks for a set of value entries under each driver’s key in the Services tree to determine whether and when to load the driver. A driver can store additional driver-defined data under its key in the Services tree. Information stored under this key is available to the driver during its initialization. This is the safest place to preserve data that is vital to your driver, because the data is stored in the system hive. The system takes extra precautions to protect the system hive (for example, keeping multiple copies). For additional information about the Services database, refer to the Services overview in the Win32 SDK online documentation.

HKEY_LOCAL_MACHINE\SOFTWARE

Use this tree to store information about the driver software.