コード例 #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Mutex mutex = new Mutex(true, Process.GetCurrentProcess().ProcessName, out canCreateNew);

            //加载配置文件
            try
            {
                if (File.Exists(confpath))
                {
                    XmlDocument xd = new XmlDocument();
                    xd.Load(confpath);
                    string xml = Helpler.Serialize(xd);
                    history = Helpler.DeSerialize <History>(xml);
                }
                if (history == null)
                {
                    history = new History();
                }
            }
            catch { }
            if (canCreateNew)
            {
                Application.Run(new MainFrm());
            }
            else
            {
                CMessageBox.Show(null, "程序已经在运行", "提示");
            }
            //Application.Run(new Form1());
        }
コード例 #2
0
        //程序关闭 保存配置
        private void CloseFrm(object sender, FormClosingEventArgs e)
        {
            XmlDocument xd  = new XmlDocument();
            string      xml = Helpler.Serialize(Program.history);

            xd.LoadXml(xml);
            xd.Save(Program.confpath);
        }