Partager via


Using the Hive-based Registry

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 entry to your device configuration.

  2. Verify the following registry settings in the Platform.reg file.

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

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

  3. Set the following registry value in the Platform.reg file to determine the default user 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. These drivers are used to access the persistent file system where the hives are stored.

    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 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. This indicates that the file system contains the following registry key.

    [HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\<ProfileName>\<FileSystemName>]
        "MountFlags"=dword:2
    
  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 OS 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. You can call RegFlushKey when no data has changed; in that case, the file will not be touched. RegFlushKey should be called on both the OS 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 | Upgrading the Hive-based Registry | Hive-based Registry Setup

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.