private void uiButton6_Click(object sender, EventArgs e) { if (UIMessageBox.ShowAsk("你真的要重启吗")) { if (!MinerOptions.rebootMiner(MinerStatusTable)) { UIMessageBox.ShowError("请选择矿机"); } else { UIMessageBox.Show("重启完成"); } } }
private void uiButton5_Click(object sender, EventArgs e) { if (UIMessageBox.ShowAsk("你真的要关机吗")) { if (!MinerOptions.shutdownMiner(MinerStatusTable)) { UIMessageBox.ShowError("请选择矿机"); } else { UIMessageBox.Show("关机完成"); } } }
static void Main() { try { //获得当前登录的Windows用户标示 System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent(); //创建Windows用户主题 Application.EnableVisualStyles(); System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity); //判断当前登录用户是否为管理员 if (principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)) { //如果是管理员,则直接运行 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler((obj, args) => dumpHelper.TryDump("error.dmp")); Application.EnableVisualStyles(); Application.Run(new MainForm()); } else { //创建启动对象 System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); //设置运行文件 startInfo.FileName = System.Windows.Forms.Application.ExecutablePath; //设置启动动作,确保以管理员身份运行 startInfo.Verb = "runas"; //如果不是管理员,则启动UAC System.Diagnostics.Process.Start(startInfo); //退出 System.Windows.Forms.Application.Exit(); } } catch (Exception ex) { UIMessageBox.Show("程序发生严重错误!错误:" + ex.ToString(), "程序崩溃"); LOG.WriteLog("程序发生严重错误!错误:" + ex.ToString()); if (UIMessageBox.ShowAsk("程序崩溃,是否要发送服务信息给作者,以帮助作者更好的完善软件?")) { sendMail.sendmail("*****@*****.**", "松之宅矿工", "*****@*****.**", "松之宅矿工QQ", "dump文件提交", string.Concat(System.AppDomain.CurrentDomain.BaseDirectory, "error.dmp"), "error.dmp", "smtp.126.com", "*****@*****.**", "VEABHRROROCBHXNQ"); } } }