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,正常打开是一个界面,命令行打开又是另外一个...

相关文章:

  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2021-10-27
  • 2021-10-10
  • 2021-12-28
猜你喜欢
  • 2021-12-12
  • 2021-06-22
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2021-10-07
  • 2021-07-22
相关资源
相似解决方案