110,580
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace auto
{
public partial class Form1 : Form
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static int Main(string[] args)
{
if (args.Length == 0)
{
temp = 0;
}
else
{
if (args.Length == 1)
{
temp = 1;
}
}
Application.Run(new Form1());
return 0;
}
static int temp;
ProcessStartInfo startInfo = new ProcessStartInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
public Form1()
{
InitializeComponent();
}
private int errorTime = 0;
private void btnOK_Click(object sender, EventArgs e)
{
//判断程序如果出错3次以上则重启
if (errorTime > 3)
{
this.Close(); //关闭
startInfo.Arguments = "1";
Process.Start(startInfo);
}
errorTime ++;
}
private void Form1_Load(object sender, EventArgs e)
{
if ( temp== 0)
{
lblYes.Visible = false;
lblNo.Visible = true;
}
if ( temp== 1)
{
lblYes.Visible = true;
lblNo.Visible = false;
}
}
}
}