Change a registry value in VB.NET -


After

I have searched a lot to find a solution for my problem, but I can not find any specific solutions is.

I need to change a value that is stored under HKEY_LOCAL_MACHINE \ SOFTWARE \ APP_NAME . It is not possible to use .NET's registry functions, because they are not strict restrictions.

The following snippet should resolve my problem:.

  Smoothed RegKey RegistryKey as a dim, in the form of ver as decimal RegKey = My.Computer.Registry.LocalMachine.OpenSubKey ("HKEY_LOCAL_MACHINE \ SOFTWARE \ APP_NAME", this is true)  

regKey.SetValue ("IP", "192.168.10.15:18500") RegKey. Close ()

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

What should I do? I have imported Microsoft.Win32 and RegistryKey does not accept any manufacturer. Remove the "HKEY_LOCAL_MACHINE" key from the text, which is already covered by the localmachine member in your code.

Used to be.

Beware that this code will not work on a regular Vista or Win7 machine, you can open this key capable of writing with UAC. You need a manifest which requires admin privileges, write My.Computer.Registry.CurrentUser instead.

Another complexity is the registry virtualization if you run this on the 64-bit version of Windows. 32-bit program instead of HKLM \ Software \ Wow6432Node / HKLM \ Software keys will read and write.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -