Using linq to query the Registry
Imports System.IO
Imports System.Reflection
Imports System.Linq
Imports System.Xml.Linq
Public Class MainClass
Public Shared Sub Main
Dim LMKeys = My.Computer.Registry.LocalMachine.OpenSubKey("Software").GetSubKeyNames
Dim UserKeys = My.Computer.Registry.CurrentUser.OpenSubKey("Software").GetSubKeyNames
Dim reg = From LocalMachineKey In LMKeys, UserKey In UserKeys _
Where LocalMachineKey = UserKey _
Select LocalMachineKey, UserKey _
Order By LocalMachineKey
Console.WriteLine("Keys common to HKLM\Software and HKCU\Software:")
For Each r In reg
Console.WriteLine(r.LocalMachineKey)
Next
End Sub
End Class
Related examples in the same category