Process调用winform程序

 

调用者:

       string path = @"../temp.exe";
            string Name = @"temp.xml";
            using (Process p = new Process())
            {
                p.StartInfo.FileName = path;//可执行程序路径
                p.StartInfo.Arguments = Name;//参数以空格分隔,如果某个参数为空,可以传入""
                p.StartInfo.UseShellExecute = false;//是否使用操作系统shell启动
                p.StartInfo.CreateNoWindow = true;//不显示程序窗口
                p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
                p.StartInfo.RedirectStandardInput = true;   //接受来自调用程序的输入信息
                p.StartInfo.RedirectStandardError = true;   //重定向标准错误输出
                p.Start();
                Console.WriteLine(p.StandardOutput.ReadToEnd());  
                p.WaitForExit();
            }

被调用者:

创建一个winform程序

上面的 p.StartInfo.Arguments 传入的参数就在 Program.cs 中 Main 中的 args 参数

这样取值:
args[0] args[1] args[2] ..........

想使用WebBrowser是要在Form中加载对象

 

posted @ 2020-12-07 16:01  sunshuaize  阅读(431)  评论(0编辑  收藏  举报