日期:2014-05-18  浏览次数:20650 次

请教一个非常邪门的问题System.Diagnostics.Process.Start
我用System.Diagnostics.Process.Start 开启一个程序,这个程序是读写注册表的。用C++写的。问题是当我通过这种方式并且看见其执行完成,但注册表内容没变,也没返回错误,而我单独去运行C++这个程序,也显示执行完成,但其注册表确实改变了。我想请问哪块出问题了。已经调用,并已经执行了,为什么注册表没有改变呢。

------解决方案--------------------
C# code
Process p = new Process();
p.StartInfo = new ProcessStartInfo()
            {
                FileName = fileName,
                Arguments = arguments,
                UseShellExecute = false,                          
                RedirectStandardOutput = true,          
                RedirectStandardError = true,           
                CreateNoWindow = false,                  
                WindowStyle = ProcessWindowStyle.Normal
            };
p.Start();
output = p.StandardOutput.ReadToEnd();
error = p.StandardError.ReadToEnd();   //打印出来看看
p.WaitForExit();