我一直在试图将注册表文件导出并保存到任意位置,代码正在运行。但是,在指定路径和保存时,该功能不起作用,也不会导出注册表。没有显示任何错误。如何在C中导出注册表#
private static void Export(string exportPath, string registryPath)
{
string path = "\""+ exportPath + "\"";
string key = "\""+ registryPath + "\"";
// string arguments = "/e" + path + " " + key + "";
Process proc = new Process();
try
{
proc.StartInfo.FileName = "regedit.exe";
proc.StartInfo.UseShellExecute = false;
//proc.StartInfo.Arguments = string.Format("/e", path, key);
proc = Process.Start("regedit.exe", "/e" + path + " "+ key + "");
proc.WaitForExit();
}
catch (Exception)
{
proc.Dispose();
}
}
你在捕捉异常,然后既不显示也不记录它,所以我希望不会显示错误。你至少可以把catch变成一个'Exception e'并在其中插入一个'Console.WriteLine(e.Message)'。或者如果调试,只需在'catch'块中放置一个断点并查看异常情况。 – 2013-05-01 11:04:33
我为异常创建了一个对象,并试图在消息框中显示它(如果存在)。没有例外 – 2013-05-01 11:11:21
请您发布注册表项名称的示例,例如,您是否使用“HKLM”或“HKEY_LOCAL_MACHINE”,您是否确实拥有足够的权限来访问注册表项 – 2013-05-01 11:15:07