C#怎样调用外部应用程序?

来源:互联网 发布:新纪元期货交易软件 编辑:程序博客网 时间:2024/04/30 11:05
/// <summary>
/// 启动外部应用程序
/// </summary>
/// <param name="appName">应用程序路径名称</param>
/// <param name="arguments">启动参数</param>
/// <returns>true表示成功,false表示失败</returns>
public static bool StartApp(string appName,string arguments)
{
 Process p = new Process();
 p.StartInfo.FileName = appName;//exe,bat and so on
 p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
 p.StartInfo.Arguments = arguments;
 try
 {
  p.Start();
  p.WaitForExit();
  p.Close();
 }
 catch(Exception e)
 {
  e.ToString();
  return false;
 }
 return true;
}
//把应用程序名和参数传进去就行了.
原创粉丝点击