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 } }
时间: 2024-11-08 18:27:00