在intel852板子上实现WinCE保存注册表功能

这些天在帮客户解决不能保存注册表的问题.

之前在国半GX3的板子上实现过保存注册表的功能,就是按照网上流传的方法:加HIVE组件, 加FAT支持,加ATAPI驱动, 再在platform.reg中添加一些代码就可以了.但客户用的是intel852芯片组的板子,按照上述方法build出来的NK无法启动到桌面.据客户的工程师讲,当"Start DevMgr"=dword:1时无法启动,而当"Start DevMgr"=dword:0时可以启动但无法保存注册表.

我查了一下MSDN, 与"Start DevMgr"相关的描述如下:
[HKEY_LOCAL_MACHINE/init/BootVars]
    "SystemHive"="<your system hive location>"
    "ProfileDir"="<your user hive location>"
    "Flags"=dword:<your value>
The Flags value indicates in which boot phase Storage Manager or Device Manager start, and whether the registry affected is a hive-based registry or a registry in external ROM. This value replaces Start DevMgr. It offers more precise control without sacrificing the previous functionality. For example,
"Flags"=dword:3
where 3 indicates the sum of bits 1 and 2, is equivalent to
"Start DevMgr"=dword:1
If no flags are set, Device Manager and Storage Manager do not start and the hive is stored in the object store. Because hives that are stored in the object store are lost on a cold boot, hives are typically stored outside RAM, making it necessary to start the Device Manager.

相关网址:http://msdn2.microsoft.com/en-us/library/ms892395.aspx

也就是说想保存注册表,"Start DevMgr"=1是必须的.
关于无法保存注册表问题,MSDN的相关网址为:http://msdn2.microsoft.com/en-us/library/ms900964.aspx
其中:

The build succeeds but it hangs soon after boot. The following list shows possible causes and solutions:
The Device Manager never started.
Set Start DevMgr = 1. See the description of registry settings in the setup instructions.

The Device Manager started but the necessary file system did not.
Be sure all registry entries for that file system, block driver, and so on are in the boot registry. See driver registry settings described in the setup instructions. Also, be sure the file system driver has the flag set to load it in the first boot phase.

对照我们的情况分析后感觉应该是IDE驱动的问题,查看intel的驱动,在ATAPI.reg中看到将驱动信息加到注册表里的一段代码并没有在; HIVE BOOT SECTION和; END HIVE BOOT SECTION之间.于是修改些段代码后问题得以解决.

另外关于写注册表有两种方法,一个是设置"RegistryFlags"=dword:1, 这样在系统修改注册表信息后会直接将此信息写回到存储上面的注册表文件中.不过这样可能会导致系统看起来有一点点慢,另外一个方法是在关机,挂起或重启时将内存中的注册表信息写回注册表文件.
对应的函数是:LONG RegFlushKey(HKEY hKey );
hKey值可以是HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS. 

总结一下:关于Start DevMgr的问题,在网上看到也有其它人遇到过这个问题,但都是只有问题没有答案,不知是一直没解决还是解决了没有贴出来. 出现这个问题应该首先看一下相应的驱动信息加了没有,加对了没有.

这个问题从开始发现问题到解决用了差不多一周多的时间,出现问题后一个正确的分析方向是非常重要的,可以少走很多弯路,另外有了问题多看一下MSDN的帮助,在那里总能找到你想知道的东西.

祝大家好运!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值