我想讓winrar Process窗口不可見。當我使用Process類啓動winrar時,如何使窗口不可見
這行代碼似乎沒有任何效果:
//the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
我怎樣才能做到這一點的窗口保持隱藏?
這是我用WinRAR的啓動代碼:
public void compress(string inputfilename, string outputfilename, string workingfolder)
{
string the_rar;
RegistryKey the_Reg;
object the_Obj;
string the_Info;
ProcessStartInfo the_StartInfo;
Process the_Process;
try
{
the_Reg = Registry.ClassesRoot.OpenSubKey(@"WinRAR\shell\open\command");//for winrar path
the_Obj = the_Reg.GetValue("");
the_rar = the_Obj.ToString();
the_Reg.Close();
the_rar = the_rar.Substring(1, the_rar.Length - 7);
the_Info = " a " + " " + outputfilename + " " + " " + inputfilename;//i dare say for parameter
the_StartInfo = new ProcessStartInfo();
the_StartInfo.FileName = the_rar;
the_StartInfo.Arguments = the_Info;
the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
the_StartInfo.WorkingDirectory = workingfolder;
the_Process = new Process();
the_Process.StartInfo = the_StartInfo;
the_Process.Start();//starting compress Process
the_Process.Close();
the_Process.Dispose();
}
catch
{
}
}
爲什麼不使用本機庫而不是使用shelling? –
@Kaboo'WinRar'附帶一個命令行工具('Rar.exe'和'Unrar.exe')來壓縮/解壓檔案。您可能想嘗試使用它而不是使用GUI('WinRar.exe')。 – IronGeek