注册 登录
编程论坛 VB.NET论坛

注册表如何读写reg_bianry数据?

calf18 发布于 2010-10-15 10:35, 1085 次点击
注册表中字符串的读写已经解决,但reg_bianry数据如何读写,有几点疑问:

1、注册表中显示的值(hex)和以下语句读取bytevalue的值不一样:

Dim subvalue() As String,currentuser As RegistryKey,bytevalue() As Byte
currentuser = ("Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedPidlMRULegacy", True)
subvalue = currentuser.GetValueNames
j = subvalue.GetUpperBound(0)
For i = 0 To j
    bytevalue = currentuser.GetValue(subvalue(i))
Next

2、如何将bytevalue转换成字符串,用System.Text.Encoding.Unicode.GetString(bytevalue)只能得到一部分;

3、如何写入reg_binary值,以下语句不行

currentuser.SetValue(valuekey, setbytevalue, RegistryValueKind.Binary)
setbytevalue为byte数组
2 回复
#2
不说也罢2010-10-15 13:20
你这样肯定读不出来准确的
程序代码:

        Dim subvalue() As String, currentuser As RegistryKey, bytevalue() As Byte
        currentuser = ("Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedMRU")
        '上面这行请键入准确的注册表键值
        subvalue = currentuser.GetValueNames
        Dim s As String
        For Each s In subvalue
            Dim mykind As RegistryValueKind = currentuser.GetValueKind(s)
            Select Case mykind
                Case RegistryValueKind.Binary
                    bytevalue = CType(currentuser.GetValue(s), Byte())
                    MsgBox(System.Text.Encoding.Unicode.GetString(bytevalue))
            End Select
        Next s

#3
liuliang97672010-10-19 13:37
http://www.

JAVA开发工程师
ss
北京搜狐互联网信息服务有限公司
公司类型:民营公司 公司规模:150-500人 ss
发布时间 :2010-09-28 工作年限 :不限 工作方式 :全职 薪金待遇 :面议 性别要求 :不限 招聘人数 :25 到期时间 :2010-10-28 户口要求 :无要求
1