向WinForm程序传递命令行参数以及让程序后台运行的
2020-12-13 17:00
标签:winform style blog io color ar sp for div 向WinForm程序传递命令行参数以及让程序后台运行的 标签:winform style blog io color ar sp for div 原文地址:http://www.cnblogs.com/aoun/p/4088653.html 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 )
MessageBox.Show(args[i]);
}
MessageBox.Show("output done!");
System.Environment.Exit(0); // exit program
}
}
文章标题:向WinForm程序传递命令行参数以及让程序后台运行的
文章链接:http://soscw.com/index.php/essay/36652.html