我正在尝试找出备份windows mobile 6.1设备的整个注册表的最佳方法。我发现OPENNETCF RegistryHelper类,据说会保存一个基于hive的键?
谁能先帮我弄清楚这是否是最好的方法?
下面是我试图使用的代码,并不断得到错误"无法生成注册表文件"
private void button1_Click(object sender, EventArgs e)
{
RegistryKey Key = Registry.LocalMachine.OpenSubKey(@"SystemStorageManagerProfilesSDMMC");
string outputkey = @"Storage Cardkey.reg";
SaveHiveBasedKey(Key, outputkey);
}
public static void SaveHiveBasedKey(Microsoft.Win32.RegistryKey keyToSave, string destinationPath)
{
RegistryHelper.SaveHiveBasedKey(keyToSave, destinationPath);
}
异常细节:
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:
显然Windows Mobile使用基于Ram的注册表
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);
}