首页 > Windows开发 > 详细

向WinForm程序传递命令行参数以及让程序后台运行的

时间:2014-11-11 09:16:32      阅读:260      评论:0      收藏:0      [点我收藏+]
 1  [STAThread]
 2         static void Main(string[] args)
 3         {
 4             Application.EnableVisualStyles();
 5             Application.SetCompatibleTextRenderingDefault(false);
 6             if (args.Length == 0)
 7                 Application.Run(new Form1());
 8             else
 9                 Application.Run(new Form1(args));
10         }
public partial class Form1 : Form
    {
        string[] args = null;
        public Form1()
        {
            InitializeComponent();
        }
        public Form1(string[] args)
        {
            InitializeComponent();
            this.args = args;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (args != null)
            {
                for (int i = 0; i < args.Length; i++)
                    MessageBox.Show(args[i]);
            }          
            MessageBox.Show("output done!");
            System.Environment.Exit(0); // exit program
        }
    }

 

向WinForm程序传递命令行参数以及让程序后台运行的

原文:http://www.cnblogs.com/aoun/p/4088653.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!