Like this article? We recommend
Accessing the Registry
It’s easy to write to the registry with the My feature, but you need to be careful. Writing carelessly to the registry can make other applications run poorly, or even prevent the computer from starting correctly. Listing 5 dumps the CurrentUser keys—a read action that’s relatively safe.
Listing 5 Reading the subkeys for the current user.
Sub ReadRegistry() Dim keys() As String = My.Computer.Registry.LocalMachine.GetSubKeyNames() Dim key As String For Each key In keys Console.WriteLine(key) Next Console.WriteLine(My.Computer.Registry.CurrentUser) Console.WriteLine("press enter") Console.ReadLine() End Sub
This code is self-explanatory. One word of caution, though: Before you start reading and writing the registry, run regedt32.exe and export your current registry settings.