c#中一个进程启动另一个进程并传递参数
生活随笔
收集整理的這篇文章主要介紹了
c#中一个进程启动另一个进程并传递参数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.開啟進程
using System.Diagnostics;
?
ProcessStartInfo process = new ProcessStartInfo();
process.FileName = "要開啟的進程路徑";?
string arg1 = ?"進程參數1";
string arg2 = ?"進程參數2";
process.Arguments = string.Format("{0} {1}", arg1, arg2) ; ?//多個參數用空格隔開
process.WindowStyle = ProcessWindowStyle.Normal;
Process.Start(process);
2.修改要開啟進程的Main函數
/// <summary>
/// 應用程序的主入口點。
/// </summary>
[STAThread]
static void Main(string[] args) ? //這里的 args 就為 {arg1,arg2} 了
{
? ?Application.EnableVisualStyles();
? ?Application.SetCompatibleTextRenderingDefault(false);
? ?Application.Run(new Form1(args));
}
?
?
總結
以上是生活随笔為你收集整理的c#中一个进程启动另一个进程并传递参数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 解决: Failed to execut
- 下一篇: Windows消息ID号查看