现在有程序a.exe 和程序b.exe ,运行a.exe的某个过程中会运行b.exe ,但是b.exe只能由a.exe传递正确的参数才能运行!怎么实现啊?单独点击b.exe是无法运行的!winform!

解决方案 »

  1.   

    在a.exe的调用b.exe System.Diagnostics.Process.Start("b.exe","参数")
    b.exe 的Program里:
    static void Main(string[] parameter)
            {                Application.Run(new Form1(parameter[0].ToString()));        
    }Form1.cs的构造函数里:
    public Form_Play(string par)
            {  
       //传值可以用了
            }
      

  2.   

    直接在程序a.exe中判断你需要传送的结果,
    比如:
    if(true)
    {
         system.Diagnostics.process.start("b.exe")b 程序所在的位置
    }
      

  3.   


    namespace 程序A
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("我是程序A,我会打开程序B");
                System.Diagnostics.Process.Start("程序B.exe", "/我是程序A /请运行");
                Console.ReadLine();
            }
        }
    }namespace 程序B
    {
        class Program
        {
            static void Main(string[] args)
            {
                if (args != null && args.Length == 2)
                {
                    if (args[0] == "/我是程序A" && args[1] == "/请运行")
                    {
                        Console.WriteLine("我已出仓,感觉良好");
                        Console.ReadLine();
                    }
                }
            }
        }
    }
      

  4.   

    用Process类实例的Arguments属性System.Diagnostics.Process.Start("1.exe", "arg1  arg2  arg3");orSystem.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); 
    startInfo.FileName = "1.exe";  //参数用空格分开 
    startInfo.Arguments = "arg1"+" "+"arg2"+" "+"arg3";  
    System.Diagnostics.Process.Start(startInfo);