My.Computer.Registry.LocalMachine Property
Returns a RegistryKey type, which provides access to HKEY_LOCAL_MACHINE.
' Usage
Dim value As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine
' Declaration
Public ReadOnly Property LocalMachine As Microsoft.Win32.RegistryKey
Return Value
RegistryKey
Remarks
The My.Computer.Registry object offers methods and properties for working with registry keys. See My.Computer.Registry Object for more information.
HKEY_LOCAL_MACHINE is usually used to store settings that do not vary from user to user in Windows. All users of the computer share this key. Its five subkeys (Hardware, SAM, Security, Software, and System) hold configuration data for the local machine.
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 |
---|---|
AllAccess |
Create, read, and write access to registry variables. |
Create |
Create access to registry variables. |
NoAccess |
No access to registry variables. |
Read |
Read access to registry variables. |
Write |
Write access to registry variables. |
Tasks
The following table lists examples of tasks involving the My.Computer.Registry object.
To | See |
---|---|
Create a registry key |
How to: Create a Registry Key and Set Its Values in Visual Basic |
Delete a registry key |
|
Determine whether a value exists in a registry key |
How to: Determine if a Value Exists in a Registry Key in Visual Basic |
Read a value from a registry key |
|
Set a value in a registry key |
Example
This example opens the subkey Software\MyCompany\Preferences
and sets the value FontColor
to "red"
.
My.Computer.Registry.LocalMachine.OpenSubKey _
("Software\MyCompany\Preferences", True)
My.Computer.Registry.LocalMachine.SetValue("FontColor", "red")
Requirements
Namespace: Microsoft.VisualBasic.MyServices
Class: RegistryProxy (provides access to Registry)
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)
Permissions
No permissions are required.
See Also
Tasks
Troubleshooting: Manipulating the Registry
Reference
My.Computer.Registry Object
Microsoft.Win32.RegistryKey
Microsoft.Win32.Registry.LocalMachine
Concepts
Common Registry Tasks
Security and the Registry
Reading from and Writing to the Registry Using My