我无法从注册表中获取价值

时间:2019-11-01 06:05:36

标签: vb.net registry

我无法使用Registry.getvalue函数从注册表中获取“ REG_RESOURCE_LIST”和“ REG_FULL_RESOURCE_DESCRIPTOR”的值

但是,我能够获得其余的数据类型(REG_BINARY,REG_MULTI_SZ等)。

对于数据类型(“ REG_RESOURCE_LIST”和“ REG_FULL_RESOURCE_DESCRIPTOR”)中的代码,始终返回“ Nothing”

   Dim value = regSubKey.GetValue(SettingName)

   'Regpath1 : HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System  
   'RegPath2 : HKEY_LOCAL_MACHINE\HARDWARE\RESOURCEMAP\PnP Manager\PnpManager

    For Each SettingName In regSubKey.GetValueNames
                Dim SettingType = regSubKey.GetValueKind(SettingName)
                Dim SettingValue As String = ""
                Dim type As String = ""

                If SettingType = RegistryValueKind.Binary Then
                    type = "REG_BINARY"
                    Dim value = regSubKey.GetValue(SettingName)
                    SettingValue = BitConverter.ToString(value)
                ElseIf SettingType = RegistryValueKind.MultiString Then
                    type = "REG_MULTI_SZ"
                    Dim Data As String() = regSubKey.GetValue(SettingName)
                    SettingValue = (String.Join(" ", Data))
                    SettingValue = SettingValue.Replace(",", " ")
                ElseIf SettingType = RegistryValueKind.None Then
                    type = "REG_NONE"
                    Dim value = regSubKey.GetValue(SettingName)
                    SettingValue = BitConverter.ToString(value)
                **ElseIf SettingType = RegistryValueKind.Unknown Then 'ERROR AREA
                     'REG_RESOURCE_LIST & REG_FULL_RESOURCE_DESCRIPTOR
                     type = "UNKNOWN TYPE"
                     SettingValue = "UNKNOWN DATA"
                     ' Dim value = regSubKey.GetValue(SettingName)
                     ' SettingValue = BitConverter.ToString(value)**
                Else
                    SettingValue = regSubKey.GetValue(SettingName).ToString

                    If SettingType = RegistryValueKind.ExpandString Then
                        SettingValue = SettingValue.Replace(",", " ")
                        type = "REG_EXPAND_SZ"
                    End If

                    If SettingType = RegistryValueKind.DWord Then
                        type = "REG_DWORD"
                    End If

                    If SettingType = RegistryValueKind.QWord Then
                        type = "REG_QWORD"
                        If SettingValue = "System.Byte[]" Then
                            SettingValue = " "
                        End If
                    End If

                    If SettingType = RegistryValueKind.String Then
                        SettingValue = SettingValue.Replace(",", " ")
                        type = "REG_SZ"
                    End If
                End If
                AddData(Path, SettingName, type, SettingValue)
            Next

0 个答案:

没有答案