2008-10-31 69 views
0

我正在开发一个需要使用regini(由于遗留原因)将某些东西插入到注册表中的应用程序。我一直在试图以这样的方式来执行此操作,该应用程序的用户不知道这一点。我写了下面的代码:从c#应用程序使用regini而不打扰用户?

System.Diagnostics.ProcessStartInfo pi = new ProcessStartInfo(); 

pi.FileName = @"c:\windows\system32\regini.exe"; 
pi.Arguments = name; 
pi.WorkingDirectory = Utils.AppSettings.WorkingDirectory.ToString();  
pi.WindowStyle = ProcessWindowStyle.Hidden; 
pi.RedirectStandardError = true; 
pi.RedirectStandardOutput = true; 
pi.UseShellExecute = false; 
Process p = new Process(); 
p.StartInfo = pi; 
p.EnableRaisingEvents = true; 
p.Start(); 

不幸的是,每次执行代码时都会弹出'命令'窗口。我的印象是

pi.WindowStyle = ProcessWindowStyle.Hidden; 

会阻止。我该如何防止regini打开自己的命令窗口?

回答

2

尝试加入这一行:

pi.CreateNoWindow = true; 
相关问题