[Registry] writing multi string value to registry

  • Thread starter Frederik Jensen
  • Start date
F

Frederik Jensen

I am currently using OpenNETCF.Win32.Registry to manipulate the
registry on my WinCE4.2 device. It works great but I have one issue I
cannot solve: How do I write multi line string to the registry? In
particulair I want to write an IP address to
LocalMachine\Comm\<wireless adapter name>1\Parms\TcpIp\IpAddress.

Any suggestions? In advance, thank you.
Frederik Jensen, Judex.

--
I tried:

Private Sub myFunc1()

Dim registryKey As OpenNETCF.Win32.RegistryKey
Dim keyName As String = "Comm\PRISMNDS1\Parms\TcpIp"
Dim valueName As String = "IpAddress"

'//Returns error; ArgumentException: value is not supported type
Dim value As Object = New String() {"192", "168", "10", "29"}

'//Saves ordinary string value
'Dim value As String = "192.168.10.29"

registryKey = OpenNETCF.Win32.Registry.LocalMachine.CreateSubKey(keyName)
registryKey.SetValue(valueName, value)
registryKey.Close()

End Sub

After manually setting the IP address (Control Panel\Network and
Dial-up\wireless adapter) I have used Windows CE Remote Registry
Editor to validate that the stored address is of type Multi String.
However, when trying to retrieve the value using myFunc2 the value
returned is Nothing.

Private Sub myFunc2()

Dim registryKey As OpenNETCF.Win32.RegistryKey
Dim keyName As String = "Comm\PRISMNDS1\Parms\TcpIp"
Dim valueName As String = "IpAddress"

registryKey = OpenNETCF.Win32.Registry.LocalMachine.OpenSubKey(keyName)

'//oResponse is Nothing when trying to retrieve Multi String Value
Dim oResponse As Object = registryKey.GetValue("IpAddress")
registryKey.Close()

End Sub
 
P

Peter Foot [MVP]

Looking at the values in remote registry editor they are multi-strings, but
each ip address is a separate string therefore each string should be a
complete ip address, not just a single segment e.g.
Dim value As Object = New String() {"192.168.10.29"}

registryKey = OpenNETCF.Win32.Registry.LocalMachine.CreateSubKey(keyName)
registryKey.SetValue(valueName, value)
registryKey.Close()

If you had further ip addresses, these would be separate array items e.g.
Dim value As Object = New String() {"192.168.10.29", "192.168.10.30"}

Peter
 
D

Daniel Moth

I don't see any of the errors in either of the functions (as per your
comment).

Note that each string is a complete ip address not just a part of it, so you
should change it to something like this:
Dim value() As String = New String() {"192.168.10.29"}

Finally, and although I am not recommending it, you should find that setting
the reg value to just a string (nit an array of) still works.

Cheers
Daniel
 

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