Winfrom 重新登录

private void ReLogin_Click(object sender, EventArgs e)
        {
            ///实例化一个进程
            Process process = new Process();

            ///设置进程的应用程序
            process.StartInfo.FileName = System.AppDomain.CurrentDomain.BaseDirectory.ToString()+"QueryMachine.exe";

            ///启动指定的进程资源
            process.Start();

            ///终止正在进行的应用程序
            Application.Exit();
            bool flag = false;

            ///实例化一个同步基元
            Mutex mutex = new Mutex(true, "QueryMachine.BackManager.frmLogin", out flag);
            if (flag)
            {
                frmLogin Login = new frmLogin();
               
                if (Login.ShowDialog() == DialogResult.OK)
                {
                    Application.Run(new frmMDIMain());
                }
            }
            else
            {
                MessageBox.Show(resourceAlreadyRunning,resourceSystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Application.Exit();
            }
        }

原文地址:https://www.cnblogs.com/pato/p/1690456.html