RegistryProxy.SetValue Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Writes a value to a registry key.
Overloads
SetValue(String, String, Object) |
Writes a value to a registry key. |
SetValue(String, String, Object, RegistryValueKind) |
Writes a value to a registry key. |
SetValue(String, String, Object)
Writes a value to a registry key.
public:
void SetValue(System::String ^ keyName, System::String ^ valueName, System::Object ^ value);
public void SetValue (string keyName, string valueName, object value);
member this.SetValue : string * string * obj -> unit
Public Sub SetValue (keyName As String, valueName As String, value As Object)
Parameters
- keyName
- String
String
. Name of the key to be written to. Required.
- valueName
- String
String
. Name of the value to be written. Required.
- value
- Object
Object
. Value to be written. Required.
Exceptions
value
is Nothing
.
keyName
does not begin with a valid registry root.
-or-
valueName
is longer than the maximum length allowed (255 characters).
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.
The user does not have the permissions required to create or modify registry keys.
Examples
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")
Remarks
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 |
See also
- RegistryValueKind
- SetValue
- Objects (Visual Basic)
- Reading from and Writing to the Registry (Visual Basic)
- Security and the Registry (Visual Basic)
Applies to
SetValue(String, String, Object, RegistryValueKind)
Writes a value to a registry key.
public:
void SetValue(System::String ^ keyName, System::String ^ valueName, System::Object ^ value, Microsoft::Win32::RegistryValueKind valueKind);
public void SetValue (string keyName, string valueName, object value, Microsoft.Win32.RegistryValueKind valueKind);
member this.SetValue : string * string * obj * Microsoft.Win32.RegistryValueKind -> unit
Public Sub SetValue (keyName As String, valueName As String, value As Object, valueKind As RegistryValueKind)
Parameters
- keyName
- String
String
. Name of the key to be written to. Required.
- valueName
- String
String
. Name of the value to be written. Required.
- value
- Object
Object
. Value to be written. Required.
- valueKind
- RegistryValueKind
RegistryValueKind. Required.
Exceptions
value
is Nothing
.
keyName
does not begin with a valid registry root.
-or-
keyName
is longer than the maximum length allowed (255 characters).
-or-
The type of value
does not match the registry data type specified by valueKind
, therefore the data cannot be converted properly.
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.
The user does not have the permissions required to create or modify registry keys.
Examples
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")
Remarks
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 |
See also
- RegistryValueKind
- SetValue
- Objects (Visual Basic)
- Reading from and Writing to the Registry (Visual Basic)
- Security and the Registry (Visual Basic)