RegistryProxy.GetValue Method (String, String, Object)

 

Gets a value from a registry key.

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

public object GetValue(
	string keyName,
	string valueName,
	object defaultValue
)

Parameters

keyName
Type: System.String

String. Key from which the value is to be retrieved. Required.

valueName
Type: System.String

String. Value to be retrieved. Required.

defaultValue
Type: System.Object

Object. Default value to be supplied if the value does not exist. Required.

Return Value

Type: System.Object

Gets a value from a registry key.

Exception Condition
SecurityException

The user does not have the permissions required to read from the registry key.

IOException

The RegistryKey that contains the specified value has been marked for deletion.

ArgumentException

keyName does not begin with a valid registry root.

valueName is not case-sensitive.

A registry key can contain one value that is not associated with any name. When this unnamed value is displayed in the registry editor, the string "(Default)" appears instead of a name. To retrieve this unnamed value, specify either null or the empty string ("") for valueName.

The following table lists examples of tasks involving the GetValue method.

To

See

Read a value from a registry key

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

This example reads the value Name from HKEY_CURRENT_USER\Software\MyApp and displays it in a MessageBox.

Dim readValue As Object
readValue = My.Computer.Registry.GetValue(
  "HKEY_CURRENT_USER\Software\MyApp", "Name", Nothing)
MsgBox("The value is " & CStr(readValue))

RegistryPermission

to read from the registry. Associated enumeration: RegistryPermissionAccess.Read

EnvironmentPermission

to read a registry key of type REG_EXPAND_SZ. Associated enumeration: PermissionState.Unrestricted

.NET Framework
Available since 2.0
Return to top
Show: