zoukankan      html  css  js  c++  java
  • C#中怎么用process调用一个exe文件并传入参数?


    System.Diagnostics.Process.Start("程序的路径", "参数1 参数2");
    第一个参数是aaa.exe 的路径,第二个参数是用空格分开的两个参数组成的字符串。
    aaa.exe中的main方法写做
    static void Main(string[] args)
    用Process.Start启动aaa.exe时main方法的args参数就是Process.Start传入参数用转换成的长度为2的数组

    代码如下 调exe的写法:

    static void Main(string[] args)
    {
    System.Diagnostics.Process.Start(@"E:SouceCodeWindowsFormsApplication1 - 副本WindowsFormsApplication1inDebugWindowsFormsApplication1.exe", "参数1 参数2");
    }

    被调的写法:

    static void Main(string[] args)
    {
    if (args.Length > 0)
    {
    string canshu1 = args[0];
    string canshu2 = args[1];
    MessageBox.Show(canshu1);
    MessageBox.Show(canshu2);
    }
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
    }

  • 相关阅读:
    LeetCode:33. Search in Rotated Sorted Array
    重拾 ACM-HDU 2000-2009
    hdu 1022 数据结构 stack模拟
    画椭圆
    声控灯
    VC++调用R语言
    Setup Factory打包时注册com dll
    折腾树莓派的一些总结
    老调重弹
    制作cpprefernce.chm
  • 原文地址:https://www.cnblogs.com/ziqiumeng/p/8490220.html
Copyright © 2011-2022 走看看