日期:2014-05-20  浏览次数:20773 次

注册表中BINARY型数据的读取
在读取注册表16进制数据时,我采用RegistryKey类,得到数据后采用
System.Text.UnicodeEncoding   converter   =   new   System.Text.UnicodeEncoding();
byte[]   inputBytes   =converter.GetBytes(inputString);
string     inputString   =   converter.GetString(inputBytes);
方法转为字符串,但是读取字符串如“35,2E,25,6A,00,00,00,00,00,00,2E,25,6A”时,中间遇到0就切断了,只能显示前面的信息,后面的信息无法显示,请问该怎么办?

我参考了这个帖子
http://topic.csdn.net/t/20011114/12/370088.html#r_2477896
但是发现msdn里没有RegQueryValueExA

------解决方案--------------------
//参考如下代码:
//用UTF8看到5.%j和.%j

byte[] vBuffer = (byte[])vRegistryKey.GetValue(
"Binary ", null, RegistryValueOptions.DoNotExpandEnvironmentNames);
MessageBox.Show(Encoding.UTF8.GetString(vBuffer, 0, 4));
MessageBox.Show(Encoding.UTF8.GetString(vBuffer, 10, 3));