Change a registry value in vb.net

Posted by mhofer on Stack Overflow See other posts from Stack Overflow or by mhofer
Published on 2010-06-15T08:44:38Z Indexed on 2010/06/15 8:52 UTC
Read the original article Hit count: 183

Filed under:
|

Hello,

I have searched a lot to find a solution for my problem, but I can't find any specific solution.

I need to change a value which is stored under HKEY_LOCAL_MACHINE\SOFTWARE\APP_NAME. It is not possible to use .NET's registry functions, since they have drastic restrictions.

The following snippet should solve my problem:

Dim regKey As RegistryKey
    Dim ver As Decimal
    regKey = My.Computer.Registry.LocalMachine.OpenSubKey("HKEY_LOCAL_MACHINE\SOFTWARE\APP_NAME", True)
    regKey.SetValue("IP", "192.168.10.15:18500")
    regKey.Close()

Unfortunately, I get a NullReferenceExeption when I try to set the value.

What should I do? I have imported Microsoft.Win32 and RegistryKey doesn't accept any constructor...

cheers mike

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about visual-studio-2008