I am trying to figure out the best approach to backup the entire registry off of a windows mobile 6.1 device. I found the OPENNETCF RegistryHelper class that supposedly will save a hive based key?
Could someone help me figure out first if this is best approach?
Below is the code I am trying to use and keep getting error "Unable to generate registry file"
private void button1_Click(object sender, EventArgs e)
{
RegistryKey Key = Registry.LocalMachine.OpenSubKey(@"System\StorageManager\Profiles\SDMMC");
string outputkey = @"\Storage Card\key.reg";
SaveHiveBasedKey(Key, outputkey);
}
public static void SaveHiveBasedKey(Microsoft.Win32.RegistryKey keyToSave, string destinationPath)
{
RegistryHelper.SaveHiveBasedKey(keyToSave, destinationPath);
}
Exception details:
System.ComponentModel.Win32Exception was unhandled
Message="Unable to generate registry file"
ErrorCode=-2147467259
NativeErrorCode=80
StackTrace:
at OpenNETCF.Win32.RegistryHelper.SaveHiveBasedKey()
at mc9090clone.Form1.SaveHiveBasedKey()
at mc9090clone.Form1.button1_Click()
at System.Windows.Forms.Control.OnClick()
at System.Windows.Forms.Button.OnClick()
at System.Windows.Forms.ButtonBase.WnProc()
at System.Windows.Forms.Control._InternalWnProc()
at Microsoft.AGL.Forms.EVL.EnterMainLoop()
at System.Windows.Forms.Application.Run()
at mc9090clone.Program.Main()
InnerException:
Apparently Windows Mobile uses Ram based registry.
private void button1_Click(object sender, EventArgs e)
{
string outputkey = @"\key.dat";
//save registry to dat file
SaveRamBasedRegistry(outputkey);
//Restore registry file
RestoreRamBasedRegistry(outputkey);
}
public static void SaveRamBasedRegistry(string destinationPath)
{
RegistryHelper.SaveRamBasedRegistry(destinationPath);
}
public static void RestoreRamBasedRegistry(string destinationPath)
{
RegistryHelper.RestoreRamBasedRegistry(destinationPath);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.