static void Main() { string MName = Process.GetCurrentProcess().MainModule.ModuleName; string PName = Path.GetFileNameWithoutExtension(MName); Process[] myProcess = Process.GetProcessesByName(PName); if (myProcess.Length > 1) { if (Thread.CurrentThread.CurrentUICulture.ToString() == "zh-CN") { MessageBox.Show("Aurora侦测到本程式已经在运行,请勿重复打开。", "Aurora智能提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Thread.CurrentThread.CurrentUICulture.ToString() == "zh-Hant") { MessageBox.Show("Aurora偵測到本程式已經在運行,請勿重複打開。", "Aurora智慧提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else //if (Thread.CurrentThread.CurrentUICulture.ToString() == "en") { MessageBox.Show("Aurora has detected this program is already running, please do not open again.", "Aurora Intelligent Tips", MessageBoxButtons.OK, MessageBoxIcon.Information); } } //是否可以打开新进程 else { //显示桌面提示 RegistryKey MyReg, RegReminder; MyReg = Registry.CurrentUser; try { RegReminder = MyReg.CreateSubKey("Software\\Aurora\\Reminder"); if (RegReminder.GetValue("ShowDesktopReminder").ToString() == "YES") { Type type = Type.GetTypeFromProgID("Shell.Application"); object instance = Activator.CreateInstance(type); type.InvokeMember("ToggleDesktop", BindingFlags.InvokeMethod, null, instance, null); } } catch { } if (File.Exists(Application.StartupPath + "\\Aurora_Splash.exe")) { System.Diagnostics.Process.Start("Aurora_Splash.exe"); } Thread.Sleep(2500); System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcesses(); foreach (System.Diagnostics.Process p in ps) { if (p.ProcessName == "Aurora_Splash") { p.Kill(); break; } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new AuroraMain()); Application.Run(PublicClass.AuroraMain); } }
private void Setting_Load(object sender, EventArgs e) { label8.Visible = false; label9.Visible = false; textBox5.Visible = false; //默认数据保护锁的时间文本框不可见。 checkBox4.Visible = false; RegistryKey MyReg, RegProjectInfo; //声明注册表对象 MyReg = Registry.CurrentUser; //获取当前用户注册表项 try { RegProjectInfo = MyReg.CreateSubKey("Software\\Aurora\\ProjectInfo");//在注册表项中创建子项 this.textBox1.Text = (RegProjectInfo.GetValue("ProjectName")).ToString(); this.textBox2.Text = (RegProjectInfo.GetValue("Calculator")).ToString(); this.textBox3.Text = (RegProjectInfo.GetValue("Checker")).ToString(); this.textBox4.Text = (RegProjectInfo.GetValue("MyGrade")).ToString(); } catch { } RegistryKey MyReg1, RegLocker; //声明注册表对象 MyReg1 = Registry.CurrentUser; //获取当前用户注册表项 try { RegLocker = MyReg.CreateSubKey("Software\\Aurora\\Locker");//在注册表项中创建子项 if ((RegLocker.GetValue("Enabled")).ToString() == "1") { checkBox1.Checked = true; } this.textBox5.Text = (RegLocker.GetValue("Timer")).ToString(); } catch { } //全屏保护提示 RegistryKey RegFullScreen; try { RegFullScreen = MyReg.CreateSubKey("Software\\Aurora\\Locker"); if (RegFullScreen.GetValue("FullScreen").ToString() == "YES") { checkBox4.Checked = true; } else { checkBox4.Checked = false; } } catch { } //读取单元格颜色 RegistryKey RegColor; //声明注册表对象 MyReg = Registry.CurrentUser; //获取当前用户注册表项 try { RegColor = MyReg.CreateSubKey("Software\\Aurora\\Color"); //在注册表项中创建子项 pictureBox1.BackColor = ColorTranslator.FromHtml(RegColor.GetValue("CellColor").ToString()); //显示注册表的位置 } catch { } //显示桌面提示 RegistryKey RegReminder; try { RegReminder = MyReg.CreateSubKey("Software\\Aurora\\Reminder"); if (RegReminder.GetValue("ShowDesktopReminder").ToString() == "YES") { checkBox3.Checked = true; } else { checkBox3.Checked = false; } } catch { } //退出提示 try { RegReminder = MyReg.CreateSubKey("Software\\Aurora\\Reminder"); if (RegReminder.GetValue("ExitReminder").ToString() == "YES") { checkBox2.Checked = true; } else { checkBox2.Checked = false; } } catch { } }