How to get the string from binary value in Registry?

  • Thread starter Thread starter gaxjyxq
  • Start date Start date
G

gaxjyxq

Guest
I want to get the visited folder info from Registry, the location is "HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\BagMRU". I need to decode the binary values in Registry, I can decode most binary values in Registry use the function below.

Dim rk As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\BagMRU\0")
Dim b() As Byte = rk.GetValue("0")
Dim ptr As IntPtr = Marshal.AllocHGlobal(b.Length)
Dim dataLenth As Int32 = b.Length
Marshal.Copy(b, 0, ptr, dataLenth)
Dim path As New StringBuilder(512)
SHGetPathFromIDList(ptr, path)
Marshal.Release(ptr)

MessageBox.Show(path.ToString)

but some binary values cannot be decoded, for example the value below

1525598.png

The return value should be "F:\", but I cannot use the function above to get the value.

Continue reading...
 

Similar threads

I
Replies
0
Views
156
Innovators World Wide
I
D
Replies
0
Views
173
David William Smith
D
M
Replies
0
Views
97
Mike Lusicic
M
Back
Top