Manipulating the Registry

The registry is a database that stores data about applications, drivers, user preferences, and other data that Windows CE needs to perform properly. For example, a user's default preferences for Pocket Word are stored in the registry. The registry is organized in a hierarchical system of keys and values. A key is similar to a directory, and can contain values and other keys. Windows CE supports three root keys. The following table shows the three root keys that Windows CE supports, and what type of data you should store under these keys.

Key name
Contains
HKEY_LOCAL_MACHINE Hardware and driver configuration data
HKEY_CURRENT_USER User configuration data
HKEY_CLASSES_ROOT OLE and file type matching configuration data

A value is the basic piece of data that is stored in the registry, and it can be a variety of types, including string or binary. Each value has a name and an associated piece of data. For example, a device running the Windows CE, Handheld PC Professional Edition, software uses Wrap to Window in the HKEY_LOCAL_MACHINE\Software\Microsoft\Pocket Word\Settings key to store a numerical value.

The following table describes the different limits in the registry.

Limit
Description
Key or value name length 255 characters
Data size 4 KB
Key hierarchy depth Up to 16 nested subkeys

Use the registry to store data that your application needs for each session. For example, you can save the state of your application during the shutdown process. Your application can search the registry on startup to reinstate the previously saved settings. When programming with the registry, try to keep name and data size small. Note that registry values in Windows CE take up less memory than registry keys. Design your registry hierarchy to use as few keys as possible.

Note Windows CE implements the registry as a RAM-based heap file. If the RAM loses power, the registry data may be lost if the OEM has not implemented a registry backup procedure. Windows CE must then reload the initial registry from ROM.