Hello, i am trying to write a simple application to save a registry key and its subkeys and subvalues, and then to restore it once it's deleted from my CE device.
The code is then quite simple:
'Save Registry
Dim regKey As Microsoft.Win32.RegistryKey = Nothing
Try
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\myApp", False)
System.IO.File.Delete("\Flash Disk\tmp\savedkeys.txt")
OpenNETCF.Win32.RegistryHelper.SaveHiveBasedKey(regKey, "\myDir\savedkeys.txt")
regKey.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
And then restoring the keys:
'Restore Reg File
Try
OpenNETCF.Win32.RegistryHelper.RestoreHiveBasedKey("\myDir\savedkeys.txt", True)
MessageBox.Show("Complete")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Unfortunately the second action would always result as an error "unable to restore from specified registry file".
Can anyone help me on this, or indicate me an alternative way to do a registry key restore?
Many Thanks.
Eric