RegistryProxy.SetValue Method (String, String, Object)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Writes a value to a registry key.

Namespace:   Microsoft.VisualBasic.MyServices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public void SetValue(
	string keyName,
	string valueName,
	object value
)

Parameters

keyName
Type: System.String

String. Name of the key to be written to. Required.

valueName
Type: System.String

String. Name of the value to be written. Required.

value
Type: System.Object

Object. Value to be written. Required.

Exception Condition
ArgumentNullException

value is Nothing.

ArgumentException

keyName does not begin with a valid registry root.

-or-

valueName is longer than the maximum length allowed (255 characters).

UnauthorizedAccessException

The RegistryKey is read-only and thus cannot be written to; for example, it is a root-level node, or it has not been opened with write access..

SecurityException

The user does not have the permissions required to create or modify registry keys.

If the specified key or value does not exist, it is created.

Here is an example of a task involving the My.Computer.Registry.SetValue method.

To

See

Set a value in a registry key

How to: Create a Registry Key and Set Its Value in Visual Basic

This example sets the value FontColor to "red" in the key HKEY_LOCAL_MACHINE\Software\MyCompany\Preferences.

My.Computer.Registry.LocalMachine.OpenSubKey(
  "Software\MyCompany\Preferences", True)
My.Computer.Registry.LocalMachine.SetValue("FontColor", "red")

RegistryPermission

to modify the specified registry key if it exists, or to create the registry key if it does not already exist. Associated enumerations: RegistryPermissionAccess.Write, RegistryPermissionAccess.Create

.NET Framework
Available since 2.0
Return to top
Show: