Skip to content

Instantly share code, notes, and snippets.

@Laim
Last active October 24, 2019 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Laim/725d322fb40afc52f4d19f2864927563 to your computer and use it in GitHub Desktop.
Save Laim/725d322fb40afc52f4d19f2864927563 to your computer and use it in GitHub Desktop.
Get Subkeys in registry
Imports YourApp.Registry
Public Class frmMain
Private Sub btnRegGet_Click(sender As Object, e As EventArgs) Handles btnRegGet.Click
Try
lbKeys.Items.Clear()
For Each i In getKeys("SOFTWARE\Google")
lbKeys.Items.Add(i.ToString)
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class
Imports Microsoft.Win32
Public Class Registry
Shared Function getKeys(RegPath As String)
Dim Keys As New List(Of String)
Using hklm As RegistryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, IIf(Environment.Is64BitOperatingSystem, RegistryView.Registry64, RegistryView.Registry32))
Using key As RegistryKey = hklm.OpenSubKey(RegPath)
For Each i In key.GetSubKeyNames
Keys.Add(i.ToString)
Next
End Using
End Using
Return Keys
End Function
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment