PDA

View Full Version : HELP! Registry Functions in VB.NET


robinhood1995
01-02-2004, 09:00 PM
' VB.NET
Dim oReg As Microsoft.Win32.Registry
Dim oRegKey As Microsoft.Win32.RegistryKey
Dim sValue As String

'this will open a registry key under Hkey_Local_Machine
oRegKey = oReg.LocalMachine.OpenSubKey(PathToValue)
''this will open a registry key under Hkey_Current_User
oRegKey = oReg.CurrentUser.OpenSubKey(PathToValue)

'To read a value under the key
sValue = oRegKey.GetValue(Key, DefaultValue)


To change registry values:


' VB.NET
Dim oReg As Microsoft.Win32.Registry
Dim oRegKey As Microsoft.Win32.RegistryKey

'open the key
oRegKey = oReg.LocalMachine.OpenSubKey(PathToValue, True)
'set the new value
oRegKey.SetValue(KeyName, ValueToUse)