现在的位置: 首页 > 综合 > 正文

wince的永久保存

2013年07月18日 ⁄ 综合 ⁄ 共 2149字 ⁄ 字号 评论关闭

 之前提到了ROM-only File System可以将系统根目录设定到ResidentFlash到办法, 从而实现永久保存的目的,这主要是为了方便第三方软件的安装, 安装到windows目录的文件中重启之后不会消失。
      实际上不少产品还是RAM and ROM File System的, 那么怎么解决永久保存的问题? 下面是解决办法。

      1. 修改ShellFolder. 内核启动时候,filesys.exe会根据initobj.dat来创建一些系统目录和文件, 默认是在根目录,也就是RAM盘中创建Desktop, my document...这些目录。explorer.exe程序会根据注册表配置指定的Shell Folders,默认的指向上面RAM盘下filesys.exe创建的这些目录。因此, 我们可以修改注册表来重定向这些路径,指向flash到目录。 如下是一个示例:
[HKEY_LOCAL_MACHINE/System/Explorer/Shell Folders]
"My Documents"="//SDMMC//My Documents"
"Desktop"="//ResidentFlash//Desktop"
"Application Data"="//ResidentFlash//Application Data"
"Favorites"="//ResidentFlash//Favorites"
"Programs"="//ResidentFlash//Programs"
这样,重启之后, 这些目录下面的内容就不会丢失。

      2. windows目录。 这个是最重要的, 因为一些dll必须放在这个目录或者根目录下面。可是每次重启后, 都会丢失。 WinCE又没有环境变量这样的概念。 安装文件cab一般都把文件放到windows目录下面。 如何解决? 其实, LoadLibrary时候会搜索几个路径, 除了上面提到windows和根目录, 还有“当前目录”, 可以拷贝dll到当前目录。 此外, 注册表还提供了一个SystemPath到配置, 很类似环境变量, 在注册表可以指定一个或多个系统路径。查看这篇msdn:http://msdn.microsoft.com/en-us/library /ms886736.aspx

If no file name extension is specified in the lpLibFileName parameter, the default library extension .dll is appended. However, the file name string can include a trailing point character (.) to indicate that the module name has no extension.

A search path to the executable module cannot be specified.

Unless the full path to the module is specified, Windows CE searches the following path for the module:

  • The absolute path specified by the lpLibFileName parameter
  • The .exe launch directory
  • The Windows directory
  • ROM DLL files
  • An OEM-specified search path

The following registry subkey specifies a search path to use with LoadLibrary and CreateProcess:

HKEY_LOCAL_MACHINE/Loader
SystemPath=multi_sz://path1//
//path2//

The path is only searched if the path of the file being looked for is not explicitly specified.

The total length of the SystemPath value must not exceed 260 characters. If it does, the path is ignored.

A change to the SystemPath key does not take effect until a Windows CE–based device is reset.

所以,我们可以指定系统路径到ResidentFlash到某个目录。补充:可以使用WinCE cab manager工具来处理, 提取文件,修改安装路径等。 有空试试。

      3. 注册表的永久保存。 这个借由hive注册表就可以实现。 hive技术把注册表分成了3个部分, boot 和 其他。 boot部分是不需要修改的用于内核启动的, 其他部分system.hv和user.hv可以放在ResidentFlash里面。注册表可以恢复为出厂状态。filesys.exe在启动过程中会透过OEMIoCtls来询问是否恢复出厂状态。

总结: 使用RAM and ROM File System也可以到达永久保存的目的。 只是dll可能需要手动拷贝转移。 但好处是保持系统“干净”, 稳定。 装错软件比较不害怕。 而注册表也可以恢复为出厂状态。

抱歉!评论已关闭.