Reading from and Writing to the Registry Using My

The My.Computer.Registry object offers methods and properties for working with registry keys.

The Windows registry hosts information from the operating system as well as information from applications hosted on the computer. Although My.Settings is recommended for storing such information, legacy applications may make use of the registry.

For a complete list of the My.Computer.Registry members, see My.Computer.Registry Object Members.

Tasks

The following table lists examples of tasks for registry keys 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

How to: Delete a Registry Key in Visual Basic

Determine whether a value exists

How to: Determine if a Value Exists in a Registry Key in Visual Basic

Read a value

How to: Read a Value from a Registry Key in Visual Basic

Security and the Registry

Working with the registry may compromise security by allowing inappropriate access to system resources or protected information. To use these properties, you must have read and write permissions from the RegistryPermissionAccess enumeration, which controls access to registry variables. Any code running with full trust (under the default security policy, this is any code installed on the user's local hard disk) has the necessary permissions to access the registry. For more information, see RegistryPermission class.

Registry variables should not be stored in memory locations where code without RegistryPermission can access them. Similarly, when granting permissions, grant the minimum privileges necessary to get the job done.

See Also

Tasks

Troubleshooting: Manipulating the Registry

Concepts

Security and the Registry

Reference

My.Settings Object

Other Resources

Walkthrough: Creating a Registry Key and Changing Its Values