本文共 990 字,大约阅读时间需要 3 分钟。
Process.Start(string exePathAndName, string parameter);
[STAThread]
static void Main(string[] msg) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Client_Maintenance()); //******msg 就是传过来的参数 Application.Run(new Login()); } 2) 也可以在项目的启动文件,例如 login 等. 在PageLoad 事件中:string[] args = Environment.GetCommandLineArgs();
if (args.Length > 1) { txtLoginName.Text = (args[1].toString()); 注意是: args[1] } 3.其它 . 还可以得到被调用方Main方法返回的值private void button1_Click(object sender, EventArgs e)
{ Process da = new Process(); da.StartInfo.FileName = “ConsoleApplicationTest.exe”; da.StartInfo.UseShellExecute = false; da.StartInfo.RedirectStandardInput = true; da.StartInfo.RedirectStandardOutput = true; da.StartInfo.RedirectStandardError = true; da.StartInfo.CreateNoWindow = true; da.Start(); da.WaitForExit();//等待对方退出 int nn = da.ExitCode; //得到返回值 da.Close(); MessageBox.Show(nn.tostring()); }转载地址:http://kimdi.baihongyu.com/