wince 和win2000导出的注册表文件分析

RegSetValueEx()
If dwType is the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type and the ANSI version of this function is used (either by explicitly calling RegSetValueExA or by not defining UNICODE before including the WINDOWS.H file), the data pointed to by the lpData parameter must be an ANSI character string. The string is converted to Unicode before it is stored in the registry.

但是在wince平台,和PC机上导出来的reg文件的最终格式是一样的。如:
"vaule" = hex(7):31,00,30,00,2e,00,36,00,2e,00,39,00,39,00,2e,00,31,00,31,00,30,/
00,31,00,30,00,2e,00,36,00,2e,00,39,00,39,00,2e,00,31,00,/
31,00,31,00,00,00,00,00
这是一个REG_MULTI_SZ类型的注册表值。31,00为一个字符。30,00为一个字符。其它类似。31,00.....的个数可以被4整除。REG_MULTI_SZ类型的注册表值是由多个以00,00结尾的字符串组成。在最后面。是两个00,00.相当于在最后一个字符串后面又加了一个00,00。
在Wince上导入时,可以把31合到一个字节中,再把00合到一个字节中。在pc中,则是把31,00合到一个字节中。因为在wince中是unicode,在PC上是ANSI。


"新值 #1"=hex(7):11,62,31,00,00,00,00,00这个其键值表示的是:我1。
其中我===>11,62   1==>31,00为unicode编码。
这个如果想到得到其byte形式,则要调函数进行转换。从unicode转换成char的形式后,才可在PC机上向注册表中写。
 int n;
 n = WideCharToMultiByte(CP_ACP, 0, (WCHAR*)pbData, nWchar, 0, 0,NULL,NULL);
 char* buf = new char[n+1];
 memset(buf, 0, n+1);
 int nWrite = WideCharToMultiByte(CP_ACP, 0, (WCHAR*)pbData, nWchar, buf, n,NULL,NULL);
 if(nWrite != n)
  {
     AfxMessageBox("WideCharToMultiByte error");
  }
 RegSetValueEx(m_hKey, strValue, NULL, dwType, (const unsigned char*)buf, n);

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值