How can I convert a REG_BINARY value from the registry into a string ? (vb.net)

半城伤御伤魂 提交于 2019-12-06 06:57:51

Well, it's not arbitrary binary data - it's text data in some kind of encoding. You need to find out what the encoding is.

I wouldn't be surprised if Encoding.Unicode.GetString(value) worked - but if that doesn't, please post a sample (in hex) and I'll see what I can do. What does the documentation of whatever's put the data in there say?

EDIT: It looks like Encoding.Unicode is your friend, but starting from byte 12. Use

Encoding.Unicode.GetString(bytes, 12, bytes.Length-12)
Roberto

I had this problem too and i solved in this way:

I had declared a variable as:

Dim encoding As System.Text.Encoding = System.Text.Encoding.Unicode

Then I do this in a loop:

    For Each Val As String In ValueName
        data = k.GetValue(Val)
        ListRecent.Items.Add(Val & ": " & encoding.GetString(data))
    Next

So in listbox called "ListRecent" I have obtained the complete list of recent

abatishchev

Use

Function Microsoft.Win32.RegistryKey.GetValue(name as String) as Object

Also look at System.Text.Encoding and System.Text.Encoding.Unicode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!