public static void OfferCreateLnk(Q q) { SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = q.Name; sfd.Filter = MUI.GetText("Common.FileType_LNK") + "|*.lnk"; sfd.OverwritePrompt = true; if (sfd.ShowDialog() == DialogResult.OK) { string args = "/ShowWait "; args += (q.UseTItoken ? "/TI " : ""); args += (q.WorkingDir != "") ? "/Dir:\"" + q.WorkingDir + "\" " : ""; args += "/Run:\"" + q.ExeToRun + "\" " + q.Arguments; ShellLink lnk = new ShellLink(sfd.FileName); lnk.Path = Application.ExecutablePath; lnk.Arguments = args; lnk.IconPath = q.ExeToRun; int err = lnk.Save(); if (err == 0) { MessageBox.Show(MUI.GetText("Common.CreateLnkOK"), MUI.GetText("Common.OK_title"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(MUI.GetText("Common.CreateLnkFailed") + "\n\n" + Win32.WinAPILastErrMsg(err), MUI.GetText("Common.Error_title"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnOK_Click(object sender, EventArgs e) { bool RestartRequired = (Program.beClassic != chkBeClassic.Checked) | (Program.beDPIaware != chkBeDPIaware.Checked); Program.beClassic = chkBeClassic.Checked; Program.beDPIaware = chkBeDPIaware.Checked; Program.ContextMenuIntegration.RunAsSYSTEM = chkRunAsSYSTEM.Checked; Program.ContextMenuIntegration.RunAsSYSTEM_TI = chkRunAsSYSTEM_TI.Checked; Program.SaveSettings(); if (RestartRequired) { if (MessageBox.Show(MUI.GetText("Common.AskToRestart"), MUI.GetText("Common.SureBo_title"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Application.Restart(); } } DialogResult = DialogResult.OK; this.Close(); }
static void Main(string[] args) { // Load default settings if settings.xml can't be loaded try { LoadSettings(File.ReadAllText(Program.SettingsPath, Encoding.UTF8)); } catch (Exception) { LoadSettings(Properties.Resources.defaultSettings); } if (Environment.OSVersion.Version.Major < 6) { MessageBox.Show(MUI.GetText("Common.BadOS"), MUI.GetText("Common.Error_title"), MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } SuperCore.Complain += new SuperCore.ComplainHandler(SuperCore_Complain); ParseCmdLine(args); if (beDPIaware) { Win32.SetProcessDPIAware(); } Application.ApplicationExit += new EventHandler(OnApplicationExit); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); }
public static bool SaveSettings() { try { using (StreamWriter writer = new StreamWriter(Program.SettingsPath, false, Encoding.UTF8)) { XmlDocument xmlDoc = new XmlDocument(); XmlElement root = xmlDoc.CreateElement("SuperCMD"); root.SetAttribute("DPIaware", Program.beDPIaware.ToString()); root.SetAttribute("W31UI", Program.beClassic.ToString()); root.SetAttribute("Lang", MUI.GetCurrentLangName()); root.SetAttribute("Ver", Program.Ver); XmlElement Q_nodes = xmlDoc.CreateElement("QLaunch"); for (int i = 0; i <= 8; i++) { Q q = Qs[i]; XmlElement Q_node = xmlDoc.CreateElement("Q"); Q_node.SetAttribute("index", (i + 1).ToString()); if (q.Name != "") { Q_node.SetAttribute("name", q.Name); } if (q.ExeToRun != "") { Q_node.SetAttribute("exe", q.ExeToRun); } if (q.Arguments != "") { Q_node.SetAttribute("args", q.Arguments); } if (q.WorkingDir != "") { Q_node.SetAttribute("dir", q.WorkingDir); } if (!q.UseTItoken) { Q_node.SetAttribute("ti", "False"); } Q_nodes.AppendChild(Q_node); } root.AppendChild(Q_nodes); xmlDoc.AppendChild(root); xmlDoc.Save(writer); } } catch (Exception ex) { MessageBox.Show( MUI.GetText("Common.SaveSettingsFailed") + "\n\n" + ex.Message, MUI.GetText("Common.Error_title"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
private void lnkResetQ_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (MessageBox.Show(MUI.GetText("Common.AskToResetQbtn"), MUI.GetText("Common.SureBo_title"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { Program.LoadSettings(Properties.Resources.defaultSettings); RefreshQbtn(); } }
protected override void WndProc(ref Message m) { string msg = Win32._GetMessage(m); if (msg != null) { MessageBox.Show(msg, MUI.GetText("Common.Error_title"), MessageBoxButtons.OK, MessageBoxIcon.Error); } base.WndProc(ref m); }
private void frmWait_Load(object sender, EventArgs e) { if (this.Owner == null) { this.CenterToScreen(); } else { this.CenterToParent(); } lbl.Text = MUI.GetText("Common.StartingTI"); }
private void btnSelectExe_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.FileName = ""; ofd.Multiselect = false; ofd.Filter = MUI.GetText("Common.FileType_EXE") + "|*.exe;*.bat;*.cmd"; if (ofd.ShowDialog() == DialogResult.OK) { txtProgramPath.Text = ofd.FileName; } }
public static bool StartTiService() { try { Win32.TryStartService("TrustedInstaller"); return(true); } catch (Exception) { LastComplain = MUI.GetText("Common.CantStartTI") + "\n\n" + Win32.WinAPILastErrMsg(); return(false); } }
private void btnSelectExeAndRun_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.FileName = ""; ofd.Multiselect = false; ofd.Filter = MUI.GetText("Common.FileType_EXE") + "|*.exe;*.bat;*.cmd"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Q q = new Q(); q.UseTItoken = chkTI_quick.Checked; q.ExeToRun = ofd.FileName; Run(q); } }
public override string ToString() { string n = Environment.NewLine; string s = ""; if (Name != "") { s += MUI.GetText("frmQEditor.lblName") + Name + n; } s += MUI.GetText("frmQEditor.lblProgramPath") + ExeToRun + n; s += MUI.GetText("frmQEditor.lblArguments") + Arguments + n; s += MUI.GetText("frmQEditor.grpWorkingDir") + ((WorkingDir == "") ? "<AUTO>" : WorkingDir) + n; s += "TrustedInstaller: " + UseTItoken.ToString() + n; return(s); }
private void RunQbtn(Button btn) { int i = QbtnIndex(btn); Q q = Qs[i - 1]; if (q.Name == "") { MessageBox.Show(MUI.GetText("Common.AskToNameQbtn"), MUI.GetText("Common.Error_title"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Run(q); } }
public static void ComplainAndLog() { if (DebugMode) { MessageBox.Show(SuperCore.Log, "SuperCMD Log", MessageBoxButtons.OK, (LastComplain != "") ? MessageBoxIcon.Error : MessageBoxIcon.Information); } else if (LastComplain != "") { if (hLogTarget != IntPtr.Zero) { Win32._SendMessage(LastComplain, hLogTarget); } else { MessageBox.Show(LastComplain, MUI.GetText("Common.Error_title"), MessageBoxButtons.OK, MessageBoxIcon.Error); } LastComplain = ""; } }
static void SuperCore_Complain(SuperCore.ComplainReason reason, string obj) { string msg = ""; switch (reason) { case SuperCore.ComplainReason.FileNotFound: msg = MUI.GetText("Common.FileNotFound"); break; case SuperCore.ComplainReason.FileNotExe: msg = MUI.GetText("Common.FileNotExe"); break; case SuperCore.ComplainReason.CantGetPID: msg = MUI.GetText("Common.CantGetPID"); break; case SuperCore.ComplainReason.APICallFailed: msg = MUI.GetText("Common.APICallFailed"); break; default: break; } msg = msg.Replace("%1", obj); LastComplain = msg; }