C# 实现 Winform 切换用户功能
2021-03-18 17:23
标签:pat tar dir rect work 实现 star ica main 方法一: 方法二: C# 实现 Winform 切换用户功能 标签:pat tar dir rect work 实现 star ica main 原文地址:https://www.cnblogs.com/zhujie-com/p/12349294.html#region 登录部分
private void RtnLoginOK_Click(object sender, EventArgs e) //登录按钮单击事件
{
this.Hide();
FrmRoutineMain formRtnLoginOK = new FrmRoutineMain(); //新建主窗体
formRtnLoginOK.ShowDialog();
}
#endregion
#region 切换用户
private void RtnMainSwitchUser_Click(object sender, EventArgs e) //切换用户按钮单击事件
{
if (DialogResult.Yes == MessageBox.Show("您确定要退出登陆吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location, "+自己程序设置的启动参数,没有则省略");
Process.GetCurrentProcess().Kill();
}
}
#endregion
#region 登录部分
private void RtnLoginOK_Click(object sender, EventArgs e) //登录按钮单击事件
{
this.Hide();
FrmRoutineMain formRtnLoginOK = new FrmRoutineMain(); //新建主窗体
formRtnLoginOK.ShowDialog();
}
#endregion
#region 切换用户
private void RtnMainSwitchUser_Click(object sender, EventArgs e)
{
if (DialogResult.Yes == MessageBox.Show("您确定要退出登陆吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
StartExe(Application.ExecutablePath);
Thread.Sleep(1000);
Application.ExitThread();
}
}
private static void StartExe(string appName)
{
string path = appName;
Process ps = new Process();
ps.StartInfo.FileName = path;
ps.StartInfo.Arguments = "-routine";
ps.StartInfo.CreateNoWindow = true;
ps.StartInfo.WorkingDirectory = Path.GetDirectoryName(path);
ps.Start();
}
#endregion
上一篇:jQuery——属性操作
下一篇:windows环境下搭建网站
文章标题:C# 实现 Winform 切换用户功能
文章链接:http://soscw.com/index.php/essay/65860.html