启动EXE
string arg1 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
string arg2 = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "EXE_NAME";//需要启动的程序名
p.StartInfo.WorkingDirectory = Application.StartupPath;
p.StartInfo.Arguments = arg1+" "+arg2;//启动参数
p.Start();//启动
接收参数
private void Form1_Load(object sender, EventArgs e)
{
String[] CmdArgs= System.Environment.GetCommandLineArgs();
if (CmdArgs.Length > 1)
{
//参数0是它本身的路径
String arg0 = CmdArgs[0].ToString();
String arg1 = CmdArgs[1].ToString();
String arg2 = CmdArgs[2].ToString();
MessageBox.Show(arg0);
MessageBox.Show(arg1);
MessageBox.Show(arg2);
}
}