Resolved Registry value type

amnon

New member
Joined
Dec 18, 2022
Messages
3
Programming Experience
Beginner
Hello,

I'm trying to determine the type of values downloaded from the Windows registry. I checked the program step by step and I can't figure out why it doesn't recognize the type in the case loop even though the "type" variable is read correctly.

VB.NET:
 DGV.Rows.Clear()

        Using MyBaseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
            Using MySubkey = MyBaseKey.OpenSubKey(cbo_lista.Text, RegistryKeyPermissionCheck.ReadWriteSubTree)

                If MySubkey Is Nothing Then
                    MessageBox.Show("No Subky", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Else
                    If MySubkey.ValueCount > 0 Then
                        Dim varnames() As String
                        varnames = MySubkey.GetValueNames()
                        For i As Integer = 0 To MySubkey.ValueCount - 1
                            DGV.Rows.Add(MySubkey.GetValueNames(i), MySubkey.GetValue(MySubkey.GetValueNames(i).ToString))
                            Dim type As RegistryValueKind = MySubkey.GetValueKind(MySubkey.GetValueNames(i))
                            'Check value type
                            Select Case type
                                Case type = RegistryValueKind.String
                                    DGV.Rows(i).DefaultCellStyle.BackColor = Color.DarkGreen
                                Case type = RegistryValueKind.Binary
                                    DGV.Rows(i).DefaultCellStyle.BackColor = Color.Bisque
                                Case type = RegistryValueKind.DWord
                                    DGV.Rows(i).DefaultCellStyle.BackColor = Color.DarkRed
                            End Select

                        Next
                    End If

                End If
                MyBaseKey.Close()
            End Using
        End Using
 
You should do Case RegistryValueKind.String etc
 
Back
Top