Пример #1
0
        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);
                }
            }
        }
Пример #2
0
        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();
        }
Пример #3
0
 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());
 }
Пример #4
0
 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);
 }
Пример #5
0
 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();
     }
 }
Пример #6
0
        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);
        }
Пример #7
0
 private void frmWait_Load(object sender, EventArgs e)
 {
     if (this.Owner == null)
     {
         this.CenterToScreen();
     }
     else
     {
         this.CenterToParent();
     }
     lbl.Text = MUI.GetText("Common.StartingTI");
 }
Пример #8
0
        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;
            }
        }
Пример #9
0
 public static bool StartTiService()
 {
     try
     {
         Win32.TryStartService("TrustedInstaller");
         return(true);
     }
     catch (Exception)
     {
         LastComplain = MUI.GetText("Common.CantStartTI") +
                        "\n\n" + Win32.WinAPILastErrMsg();
         return(false);
     }
 }
Пример #10
0
        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);
            }
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
            }
        }
Пример #13
0
 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 = "";
     }
 }
Пример #14
0
        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;
        }