다음을 통해 공유


Implementing the Hive-Based Registry (Windows Embedded CE 6.0)

1/6/2010

This section covers the procedure for implementing the hive-based registry. After you have implemented the hive-based registry you can save registry data across a cold boot of the OS.

To use the hive-based registry

  1. Add the hive-based registry catalog item to your operating 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 phase of startup 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 phase of startup:

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

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

  6. Set the profile for the file system driver that contains the registry.

    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 one of the following registry keys:

    • Windows CE 5.0 and later

      [HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\<ProfileName>\<FileSystemName>]
         "MountBootable"=dword:1
      
    • Versions earlier than Windows CE 5.0:

      [HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\<ProfileName>\<FileSystemName>]
         "MountFlags"=dword:2
      

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

  7. Decide whether a registry flushing mechanism is necessary.

    Outstanding registry data is flushed on a suspend or resume cycle and anytime 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 flushes any unsaved changes in the hive to the persistent file. It does not damage anything to call RegFlushKey when no data has changed. In that case, the file is not changed. RegFlushKey should be called on both the system hive HKEY_LOCAL_MACHINE and the user hive HKEY_CURRENT_USER.

See Also

Concepts

Hive-Based Registry
Hive-based Registry Setup
Troubleshooting the Hive-Based Registry
Data Persistence with the Hive-Based Registry
FAT File System Registry Settings