C#系统注销功能

来源:互联网 发布:淘宝衣服洗过会被发现 编辑:程序博客网 时间:2024/05/01 22:51
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Windows.Forms;  
  5.   
  6. namespace Cancel  
  7. {  
  8.     static class Program  
  9.     {  
  10.         /// <summary>  
  11.         /// 应用程序的主入口点。  
  12.         /// </summary>  
  13.         [STAThread]  
  14.         static void Main(string[] strArg)  
  15.         {  
  16.             Application.EnableVisualStyles();  
  17.             Application.SetCompatibleTextRenderingDefault(false);  
  18.             Application.Run(new Form1(strArg));  
  19.         }  
  20.     }  
  21. }  
  22.   
  23.   
  24.   
  25. using System;  
  26. using System.Collections.Generic;  
  27. using System.ComponentModel;  
  28. using System.Data;  
  29. using System.Drawing;  
  30. using System.Linq;  
  31. using System.Text;  
  32. using System.Windows.Forms;  
  33. using System.Diagnostics;  
  34.   
  35. namespace Cancel  
  36. {  
  37.     public partial class Form1 : Form  
  38.     {  
  39.         string[] strargs;  
  40.         public Form1(string[] strarg)  
  41.         {  
  42.             InitializeComponent();  
  43.             strargs = strarg;  
  44.         }  
  45.   
  46.         private void button1_Click(object sender, EventArgs e)  
  47.         {  
  48.            // MessageBox.Show();  
  49.             Process sprs = new Process();  
  50.             sprs.StartInfo.FileName = Application.ExecutablePath.Trim();  
  51.             sprs.StartInfo.Arguments = "注销回来的";  
  52.             sprs.Start();            
  53.             Process.GetCurrentProcess().Kill();  
  54.         }  
  55.   
  56.         private void Form1_Load(object sender, EventArgs e)  
  57.         {  
  58.             MessageBox.Show(strargs[0]);  
  59.         }  
  60.     }  
  61. }  


---------------方法二
//点击注销按钮事件里面写:
if (MessageBox.Show("您确定要注销登录吗?""提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
 
    Application.Exit();                          
    System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
 }


0 0
原创粉丝点击