OpennetCF setvalue registry problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have been trying to get the opennetcf.win32.Registry setvalue function to
work on a Pocket PC 2002. I can view the registry value but can not update. I
have looked at alot of samples and nobody seams to have any problems with it.

I have textbox on the form.

Dim reg_reader As OpenNETCF.Win32.Registry
TextBox1.Text =
reg_reader.LocalMachine.OpenSubKey("DSMobile").GetValue("Server")
reg_reader.LocalMachine.Close()

The textbox has the value at this point, OK

Now I change the textbox and want to save the change.

Dim reg_reader As OpenNETCF.Win32.Registry
reg_reader.LocalMachine.OpenSubKey("DSMobile", True).GetValue("Server")
reg_reader.LocalMachine.SetValue("Server", TextBox1.Text)
reg_reader.LocalMachine.Close()

Wont save the change, no errors, I can change with a regedit program?
Any ideas?
 
' from memory
Dim rk as RegistryKey = OpenNETCF.Win32.Registry.OpenSubKey("DSMobile",
True).
rk.SetValue("Server", TextBox1.Text)
rk.Close()

Also note that while VB.NET today allows you to call static methods on
instance variables, it isn't considered good practise (and is fixed in the
next version). I.e. you don't need Dim reg_reader...

Cheers
Daniel
 
Daniel,
I kept looking at sample code and got this to work late last night. You code
looks cleaner, I will give it a try.
Thanks for the help,

Dim regVersion As OpenNETCF.Win32.RegistryKey
Dim keyName As String = "DSMobile"
regVersion = OpenNETCF.Win32.Registry.LocalMachine.OpenSubKey(keyName, True)
regVersion.SetValue("Server", TextBox1.Text)
 
After calling SetValue remember to call regVersion.Close() to close the key
cleanly.

Peter
 
Back
Top