static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Win.Login login = new Win.Login(); login.BackgroundImage = System.Drawing.Image.FromFile(System.IO.Path.Combine(Application.StartupPath, "login.png")); login.Wait = true; login.Show(); int check = CheckAppLong(); if (check != 0) { login = new Win.Login(false, null); login.Show(); if (check == 4) { MessageBox.Show("加密狗文件不对!", "速录宝"); } else if (check == 5) { MessageBox.Show("加密狗文件内容不对!", "速录宝"); } else { MessageBox.Show("加密狗不对,请插入正确的加密狗!", "速录宝"); } Application.Exit(); return; } login.Wait = false; CheckTh = new System.Threading.Thread(new System.Threading.ThreadStart(CheckLong)); CheckTh.IsBackground = true; CheckTh.Start(); int iProcessNum = 0; foreach (Process singleProc in Process.GetProcesses()) { if (singleProc.ProcessName == Process.GetCurrentProcess().ProcessName) { iProcessNum += 1; } } if (iProcessNum <= 1) { //不要重复运行程序 MIme = new Win.WinInput(); Application.Run(MIme); } }
private static void CheckLong() { System.Threading.Thread.Sleep(1000); int checkount = 0; int checkflag = 1; while (true) { try { ce: checkflag = CheckAppLong(); if (checkflag != 0) { checkount++; if (checkount < 4) { System.Threading.Thread.Sleep(1000); goto ce; } else { break; } } else { checkflag = 0; checkount = 0; } } catch { checkflag = 3; } //System.Threading.Thread.Sleep(3000); System.Threading.Thread.Sleep(1000 * 60 * 4); } if (checkflag != 0) { if (MIme != null) { Win.WinInput.Input.indexComplete = false; } var login = new Win.Login(false, null); login.Show(); MessageBox.Show("加密狗不对,请插入正确的加密狗!", "速录宝"); if (MIme != null) { Win.WinInput.Input.indexComplete = false; MIme.ExitSelect(null, null); } Application.Exit(); } }