saptechnique

Better late than never. - 郭富

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

启动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);
            }
        }

posted on 2009-10-24 09:52  guofu  阅读(806)  评论(0编辑  收藏  举报