zoukankan      html  css  js  c++  java
  • c# winform程序如何获取命令行带参数启动时的参数

    Program.cs

        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main(string[] args)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                if (args.Length > 0)
                {
                    Application.Run(new BgControlForm(args));
                }
                else 
                {
                    Application.Run(new Form1());
                }
                
            }
        }

     

    在此基础上,写一个带参数的form构造函数

    BgControlForm  
            public BgControlForm(string[] args)
            {
                InitializeComponent();
                MessageBox.Show(args[0]);
            }

    备注: 我这里因为需求特殊,我创建了两个Form,正常打开是一个界面,命令行打开又是另外一个...

  • 相关阅读:
    求a,b在区间上的公倍数个数
    最长非上升子序列的长度
    uva 11992 线段树
    hdu 5464 dp
    hdu 5465 树状数组
    hdu 5459 递推
    poj 2528 动态线段树
    hdu 4474 bfs
    ural 1495 bfs
    hdu 2795 线段树
  • 原文地址:https://www.cnblogs.com/yimu/p/QIUGF.html
Copyright © 2011-2022 走看看