Use of Registry.CurrentUser in VB.NET

CurrentUser is used to work with Registry keys of the current user who log-in in the system at present time.
  • 3094

What is Registry

Registry we called windows registry which is used to adding a value or modifying it using the Registry Editor (regedit). It is a hierarchical database that stores configuration settings and options on Microsoft Windows operating systems. It stores informations related to Windows and other installed application on your system, but also Hardware. It contains settings for low-level operating system components as well as the applications running on the different platforms.

What CurrentUser stands in Registry.CurrentUser.

CurrentUser: CurrentUser is used to work with Registry keys of the current user who log-in in the system at present time. The Registry keys are similar to folders - in addition to values, each key can contain subkeys, which may contain further subkeys, and so on.

What we can do with Registry keys

We can do with Registry Keys:

  • Add a registry key/value.
  • Read a registry value.
  • Delete a key or a value.
  • Changing a value or a key.

So, here in this article I given an example of using Registry.CurrentUser:

Example:

Imports
 System
Imports
 Microsoft.Win32
 
Class machineReg
 

    Public Shared Sub Main()
 
        Dim a As RegistryKey = Registry.CurrentUser
        showKeys(a)
    End Sub

     Shared Sub showKeys(ByVal rkey As RegistryKey)
 
        Dim names As String() = rkey.GetSubKeyNames()
 
        Dim count As Integer = 0
 
        Console.WriteLine("Subkeys of " & rkey.Name)
        Console.WriteLine("------------------------")
 
        Dim i As String
        For Each i In names
            Console.WriteLine(i)
            count += 1
            If count >= 5 Then
                Exit For
            End If
        Next i
        Console.ReadLine() 
    End Sub
End Class

Output:

key.gif

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.