This documentation is archived and is not being maintained.

My.Computer.Registry.CurrentUser Property 

Returns a RegistryKey type which provides access to HKEY_CURRENT_USER.

' Usage
Dim value As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser
' Declaration
Public ReadOnly Property CurrentUser As Microsoft.Win32.RegistryKey


The My.Computer.Registry object offers methods and properties for working with registry keys. See My.Computer.Registry Object for more information.

HKEY_CURRENT_USER is primarily used to store per-user settings, such as colors and fonts, in Windows. The key differ according to the user.

The RegistryPermission class, which is in the System.Security.Permissions namespace, controls access to registry variables. Registry variables should not be stored in memory locations where code without RegistryPermission can access them. Similarly, when granting permissions, grant the fewest privileges necessary to get the job done.

Registry permission access values are defined by the RegistryPermissionAccess enumeration. The following table details its members.

Value Description


Create, read, and write access to registry variables.


Create access to registry variables.


No access to registry variables.


Read access to registry variables.


Write access to registry variables.

The following table lists examples of tasks involving the My.Computer.Registry object.

This example deletes the subkey Software\MyCompany\Preferences\UserData.

My.Computer.Registry.CurrentUser.DeleteSubKey _

Namespace: Microsoft.VisualBasic.MyServices

Class: RegistryProxy (provides access to Registry)

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

No permissions are required.