Don't Understand How To Write Value To Registry

G

Guest

Hello all,

I am trying to store a value in the registry using VS2003 and SDF1.4. It
does not error out, yet it does not write the value to the registry either.
Below is my code:

Dim regKey As RegistryKey
Dim keyName As String = "\Comm\TIACXWLN1\Parms\TcpIp"
Dim valueName As String = "IpAddress"
Dim regValue As String

Try
regKey =
OpenNETCF.Win32.Registry.LocalMachine.CreateSubKey(keyName)
OpenNETCF.Win32.Registry.LocalMachine.SetValue(valueName,
"192.168.51.151")
regKey.Flush()
regKey.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

Would anyone be willing to show me what I am doing wrong here? I need to get
this working asap for a project we are doing at work.

Thanks,
 
G

Guest

Should be more like this:

regKey = Registry.LocalMachine.CreateSubKey(keyName)
regKey.SetValue(valueName, "192.168.51.151")

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top