static int Main(string[] Args) { if (Args.Length > 0) { if (Args[0] == "-regist") { RegCode reg = new RegCode(); int code = reg.RegistAssembly(Application.ExecutablePath); return(code); } if (Args[0] == "-unregist") { RegCode reg = new RegCode(); int code = reg.UnRegistAssembly(Application.ExecutablePath); return(code); } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new ConfigForm()); return(0); }
private void unregistBtn_Click(object sender, EventArgs e) { string fullPath = System.Reflection.Assembly.GetAssembly(typeof(Program)).Location; int ExitCode = regCode.UnRegistAssembly(fullPath); if (ExitCode == 0) { Process.GetCurrentProcess().Kill(); } if (ExitCode == -1) { MessageBox.Show("权限提升失败!"); } else if (ExitCode == -2) { MessageBox.Show("发生了未知错误"); } else if (ExitCode == -3) { MessageBox.Show("操作失败"); } Check_Registered(); }