private void Form1_Load(object sender, EventArgs e) { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; //System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls; //嘗試當掉就中斷離開 AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += new UnhandledExceptionEventHandler(myCrash); this.LOCK_FILE = my.pwd() + "\\lock.txt"; string COMPUTER_NAME = my.getSystemKey("COMPUTER_NAME"); if (COMPUTER_NAME == "請填寫主機名稱") { MessageBox.Show("請填寫主機名稱...請先修改 system_status.exe.config"); exit(); } textSystemName.Text = COMPUTER_NAME; if (!my.is_file(this.LOCK_FILE)) { my.file_put_contents(this.LOCK_FILE, ""); } if (my.is_file_lock(this.LOCK_FILE)) { //如果目前已是 lock 就結束 CLog("Error ... Another zip process is running... "); Form1_FormClosing(sender, null); return; } //同時最多只能跑一支 killSameProcessName(); if (!my.isProcessRunning("system_status_watchdog")) { my.system(my.pwd() + "\\system_status_watchdog.exe", -1); } //寫入目前版本 my.file_put_contents(my.pwd() + "\\version.txt", VERSION.ToString()); notifyIcon1.Visible = true; //lock file s2 = new FileStream(this.LOCK_FILE, FileMode.Open, FileAccess.Read, FileShare.None); this.LOG_PATH = my.pwd() + "\\log"; create_log_dir(); this.Text += string.Format(" - 版本:{0}", VERSION); notifyIcon1.BalloonTipText = "已縮小"; notifyIcon1.BalloonTipTitle = this.Text; notifyIcon1.Text = this.Text; this.StartPosition = FormStartPosition.CenterScreen; this.TopMost = true; this.TopMost = false; this.CenterToScreen(); //載入設定檔 //cIni.ini_init(this); //預設看要帶哪一個 //cHdd.init(this); //cRunningProgram.init(this); //tabControl1.SelectTab("tabs_running_program"); tabControl1.SelectTab("tabs_setting"); tabControl1_Click(new object(), new EventArgs()); /*if (iniData["setting"]["NAME"] == "") * { * //首次使用,需先設定 * tabControl1.SelectTab("tabs_setting"); * tabControl1_Click(new object(), new EventArgs()); * } */ switch (my.getSystemKey("RUN_AT_START").ToUpper()) { case "YES": { GLOBAL_RUN_AT_START = true; } break; } if (GLOBAL_RUN_AT_START) { //自動按 btnManual_Click(sender, e); //自動縮小 WindowState = FormWindowState.Minimized; ShowInTaskbar = false; notifyIcon1.Visible = true; notifyIcon1.ShowBalloonTip(1000); } }