Partager via


Using the Hive-Based Registry (Windows CE 5.0)

Send Feedback

Once you have chosen to use the hive-based registry as the registry for your device, you can then implement the hive-based registry. After you have implemented the hive-based registry you can then persist registry data during a cold boot of the OS.

To use the hive-based registry

  1. Add the Hive-based Registry Catalog item to your OS design.

  2. Verify the following registry settings in the Common.reg file for your OS design.

    [HKEY_LOCAL_MACHINE\init\BootVars]
        "SystemHive"="<your system hive location>"
        "Flags"=dword:<your value>
    

    For more information about configuring the registry to support the hive-based registry, see Hive-based Registry Setup.

  3. Set the following registry value in the Common.reg file for your OS design to determine the default hive to load.

    [HKEY_LOCAL_MACHINE\init\BootVars]
        "DefaultUser"="<username>"
    
  4. Verify that all registry entries necessary for starting drivers in the first boot phase are wrapped in the comments.

    The following code example shows typical comments.

    ; HIVE BOOT SECTION
    <your registry settings>
    ; END HIVE BOOT SECTION
    

    These tags are commands that tell the ROM registry builder to add the entries to the boot hive.

  5. Set the following flag bit on each driver that is loaded during the first boot phase.

    [HKEY_LOCAL_MACHINE\Drivers\...]
        "Flags"=dword:1000
    

    The flags are a bitmask to OR with any existing settings. This flag tells the Device Manager to load your driver in the first boot phase with the boot registry, and not to load it a second time in the second boot phase with the system registry. It prevents the driver from being started twice.

  6. Set flags for mounting partition as bootable.

    For Windows CE 5.0 and later, set the MountAsBootable registry value as DWORD:1.

    For earlier versions, set the MountFlags registry value equal to DWORD:2.

    Set this value on the Storage Manager profile of the file system driver for the medium that contains the registry.

    For example, if you want the hive to be contained in the MyProfile storage media with the MyFileSystem driver, place the MountAsBootable or MountFlags in the following registry key:

    [HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\<MyProfile>\<MyFileSystem>]
    

    For more information about flags for mounting partitions, see Mount Settings.

  7. Decide whether a registry flushing mechanism is necessary.

    Outstanding registry data will be flushed on a suspend or resume cycle and any time the system goes through a software shutdown. However, data may be lost if power is suddenly removed. If a software shutdown is not an option, you may need to create a thread that periodically flushes data. To ensure that data is not lost, call RegFlushKey. This will flush any unsaved changes in the hive to the persistent file. It will not damage anything to call RegFlushKey when no data has changed; in that case, the file will not be touched. RegFlushKey should be called on both the system hive HKEY_LOCAL_MACHINE and the user hive HKEY_CURRENT_USER.

See Also

Hive-Based Registry Startup Sequence | Hive-Based Registry | Troubleshooting the Hive-Based Registry | Persisting Data with the Hive-Based Registry | Hive-Based Registry Data | FAT File System Registry Settings

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.