Freigeben über


Registry Fundamentals (Windows CE 5.0)

Send Feedback

The registry is a system database that stores configuration information for applications, drivers, and the operating system (OS). The registry is most commonly use for storing state information across invocations. For example, an application might have windows that a user can move and resize. Before exiting, the application could store its windows information in the registry. Then when the application starts again, it could retrieve the information and position its windows accordingly.

The structure of the Microsoft® Windows® CE registry is similar to the registries in other versions of Windows. The registry contains a forest of data subtrees. Each subtree is composed of branches called keys, and each key can contain subkeys and/or entries. Entries are stored as name/value pairs. At the base of each subtree is the root, which is identified using a well-known constant value, or HKEY. The following table shows the root constants supported by Windows CE and gives a brief description of each.

Root key constant Description
HKEY_CLASSES_ROOT Stores file type matching and OLE configuration data.
HKEY_CURRENT_USER Stores user-specific data for the user who is currently logged in. This root points to the relevant key of HKEY_USERS. Changes made are automatically made in the user's key under HKEY_USERS.
HKEY_LOCAL_MACHINE Stores machine-specific data for device drivers and applications.
HKEY_USERS Stores data for all users including a default user.

To specify a key or entry within the registry

  • Use a text string starting at a root with subkeys separated by a backslash (\).

    [ROOT]\[Key]\[Subkey]\[Subkey or entry]
    

    Traditionally, applications store data using the following key structure.

    [ROOT]\Software\[Company name]\[Product name]
    

    For example, Microsoft stores configuration information for the game FreeCell in the HKEY_LOCAL_MACHINE\Software\Microsoft\FreeCell registry key.

    Most APIs access keys under a predetermined root; therefore, text strings used as parameters should start at the key rather than the root.

To access or modify data within the registry

  1. Open the key containing the entry using either the RegOpenKeyEx function or the RegCreateKeyEx function.
  2. Perform one of the following tasks:
  3. Close the key using RegCloseKey.

Values in the registry can be stored in several different data types. The following table shows the data types that Windows CE supports.

Value type constant Description
REG_BINARY Binary data in any form.
REG_DWORD A 32-bit number.
REG_DWORD_LITTLE_ENDIAN A 32-bit number in little-endian format. This is equivalent to REG_DWORD.

In little-endian format, a multibyte value is stored in memory from the lowest byte (the little end) to the highest byte. For example, the value 0x12345678 is stored as (0x78 0x56 0x34 0x12) in little-endian format.

REG_DWORD_BIG_ENDIAN A 32-bit number in big-endian format.

In big-endian format, a multibyte value is stored in memory from the highest byte (the big end) to the lowest byte. For example, the value 0x12345678 is stored as (0x12 0x34 0x56 0x78) in big-endian format.

REG_EXPAND_SZ A null-terminated string that contains unexpanded references to environment variables, for example, %PATH%.
REG_LINK A Unicode symbolic link. Used internally; applications should not use this type.
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.

See Also

Protected Registry Keys and Values | Hints for Using the Registry | Registry

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.