示例#1
0
        static void Main()
        {
            // 处理异常
            UserClient.LogNet = new LogNetDateTime(Application.StartupPath + @"\Logs", GenerateMode.ByEveryDay);
            // 捕获未处理的异常
            AppDomain.CurrentDomain.UnhandledException += ClientsLibrary.UserClient.CurrentDomain_UnhandledException;
            //=====================================================================
            // 为了强制只启动一个应用程序的实例

            Process process = Process.GetCurrentProcess();

            // 遍历应用程序的同名进程组
            foreach (Process p in Process.GetProcessesByName(process.ProcessName))
            {
                // 不是同一进程则关闭刚刚创建的进程
                if (p.Id != process.Id)
                {
                    // 此处显示原先的窗口需要一定的时间,不然无法显示
                    ShowWindowAsync(p.MainWindowHandle, 9);
                    SetForegroundWindow(p.MainWindowHandle);
                    System.Threading.Thread.Sleep(10);
                    Application.Exit();// 关闭当前的应用程序
                    return;
                }
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //===================================================================
            // 运行主窗口之前先进行账户的验证
P1:

            FormLogin login = new FormLogin();

            if (login.ShowDialog() == DialogResult.OK)
            {
                login.Dispose();
                FormMainWindow fmw = new FormMainWindow();
                Application.Run(fmw);
                if (QuitCode == 1)
                {
                    // 继续显示登录窗口
                    QuitCode = 0;
                    goto P1;
                }
            }
            else
            {
                login.Dispose();
            }
        }
示例#2
0
文件: Program.cs 项目: seasky100/C-S-
        static void Main()
        {
            //=====================================================================
            //为了强制只启动一个应用程序的实例

            Process process = Process.GetCurrentProcess();

            //遍历应用程序的同名进程组
            foreach (Process p in Process.GetProcessesByName(process.ProcessName))
            {
                //不是同一进程则关闭刚刚创建的进程
                if (p.Id != process.Id)
                {
                    //此处显示原先的窗口需要一定的时间,不然无法显示
                    ShowWindowAsync(p.MainWindowHandle, 9);
                    SetForegroundWindow(p.MainWindowHandle);
                    System.Threading.Thread.Sleep(10);
                    Application.Exit();//关闭当前的应用程序
                    return;
                }
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //===================================================================
            //运行主窗口之前先进行账户的验证
P1:

            FormLogin login = new FormLogin();

            if (login.ShowDialog() == DialogResult.OK)
            {
                login.Dispose();
                FormMainWindow fmw = new FormMainWindow();
                Application.Run(fmw);
                if (QuitCode == 1)
                {
                    //继续显示登录窗口
                    QuitCode = 0;
                    goto P1;
                }
            }
            else
            {
                login.Dispose();
            }
        }
示例#3
0
        static void Main()
        {
            //=====================================================================
            //为了强制只启动一个应用程序的实例

            //Process process = Process.GetCurrentProcess();
            ////遍历应用程序的同名进程组
            //foreach (Process p in Process.GetProcessesByName(process.ProcessName))
            //{
            //    //不是同一进程则关闭刚刚创建的进程
            //    if (p.Id != process.Id)
            //    {
            //        //此处显示原先的窗口需要一定的时间,不然无法显示
            //        ShowWindowAsync(p.MainWindowHandle, 9);
            //        SetForegroundWindow(p.MainWindowHandle);
            //        System.Threading.Thread.Sleep(10);
            //        Application.Exit();//关闭当前的应用程序
            //        return;
            //    }
            //}
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //===================================================================
            //运行主窗口之前先进行账户的验证
            FormLogin login = new FormLogin();

            if (login.ShowDialog() == DialogResult.OK)
            {
                login.Dispose();
                FormMainWindow main = new FormMainWindow();
                main.起重设备   = login.起重设备;
                main.电梯设备   = login.电梯设备;
                main.一般设备台账 = login.一般设备台账;
                main.压力容器台账 = login.压力容器台账;
                main.锅炉台账   = login.锅炉台账;
                main.管道台账   = login.管道台账;
                Application.Run(main);
            }
            else
            {
                login.Dispose();
            }
        }