GetValue Method


GetValue Method

Location

My.Computer.Registry.GetValue

Syntax

     Dim result As Object = My.Computer.Registry.GetValue(keyName, _     valueName, defaultValue) 


keyName (required; String)

The hierarchy key under which to query the value for data.


valueName (required; Object)

The name of the value to be queried within the key. To retrieve the default value (the "(Default)" entry) for a particular key, use Nothing or an empty string for this parameter.


defaultValue (required; Object)

The default data to be returned if the value does not exist. To indicate no default value, use the Nothing keyword for this parameter.

Description

The GetValue method returns the data for a value entry in the registry. All values are stored within "keys," the main hierarchy nodes within the registry.

Usage at a Glance

  • You must have sufficient security permissions to read or write keys and values in the registry.

  • keyName must start with the name of a valid registry hive, such as HKEY_CURRENT_USER.

  • This function returns data as type Object. If Option Strict is set to true, you will likely need to convert the data to another type before use. For example, when retrieving string results, use the CStr function to convert the result to a String.

Example

The following code retrieves a string from the registry.

     ' ----- If the error limit is not recorded in the registry,     '       use a reasonable value like 5.     Dim errorLimit As String = CStr(My.Computer.Registry.GetValue( _        "HKEY_CURRENT_USER\Software\MyCompany\MySoftware", _        "ErrorLimit", "5")) 

Related Framework Entries

  • Microsoft.VisualBasic.MyServices.RegistryProxy.GetValue Method

  • Microsoft.Win32.RegistryKey.GetValue Method

See Also

ClassesRoot Property, CurrentConfig Property, CurrentUser Property, DynData Property, LocalMachine Property, PerformanceData Property, Registry Object, SetValue Method, Users Property




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net