private static void AddMmcCommands(SpecialCommandConfigurationElementCollection cmdList)
        {
            Icon[] IconsList = IconHandler.IconsFromFile(Path.Combine(SystemRoot.FullName, "mmc.exe"),
                                                         IconSize.Small);
            Random rnd = new Random();

            foreach (FileInfo file in SystemRoot.GetFiles("*.msc"))
            {
                MMCFile fileMMC = new MMCFile(file);

                SpecialCommandConfigurationElement elm1 = new SpecialCommandConfigurationElement(file.Name);

                if (IconsList != null && IconsList.Length > 0)
                {
                    if (fileMMC.SmallIcon != null)
                    {
                        elm1.Thumbnail = fileMMC.SmallIcon.ToBitmap().ImageToBase64(System.Drawing.Imaging.ImageFormat.Png);
                    }
                    else
                    {
                        elm1.Thumbnail = IconsList[rnd.Next(IconsList.Length - 1)].ToBitmap().ImageToBase64(System.Drawing.Imaging.ImageFormat.Png);
                    }

                    elm1.Name = fileMMC.Parsed ? fileMMC.Name : file.Name.Replace(file.Extension, "");
                }

                elm1.Executable = @"%systemroot%\system32\" + file.Name;
                cmdList.Add(elm1);
            }
        }
        public static SpecialCommandConfigurationElementCollection LoadSpecialCommands()
        {
            SpecialCommandConfigurationElementCollection cmdList = new SpecialCommandConfigurationElementCollection();

            AddCmdCommand(cmdList);
            AddRegEditCommand(cmdList);
            AddMmcCommands(cmdList);
            AddControlPanelApplets(cmdList);

            return cmdList;
        }
        private static void AddRegEditCommand(SpecialCommandConfigurationElementCollection cmdList)
        {
            string regEditFile = Path.Combine(SystemRoot.FullName, "regedt32.exe");
            Icon[] regeditIcons = IconHandler.IconsFromFile(regEditFile, IconSize.Small);
            SpecialCommandConfigurationElement regEditElm = new SpecialCommandConfigurationElement("Registry Editor");

            if (regeditIcons != null && regeditIcons.Length > 0)
            {
                regEditElm.Thumbnail = regeditIcons[0].ToBitmap().ImageToBase64(System.Drawing.Imaging.ImageFormat.Png);
            }

            regEditElm.Executable = regEditFile;
            cmdList.Add(regEditElm);
        }
        private static void AddControlPanelApplets(SpecialCommandConfigurationElementCollection cmdList)
        {
            foreach (FileInfo file in SystemRoot.GetFiles("*.cpl"))
            {
                SpecialCommandConfigurationElement elm1 = new SpecialCommandConfigurationElement(file.Name);

                Icon[] fileIcons = IconHandler.IconsFromFile(file.FullName, IconSize.Small);

                if (fileIcons != null && fileIcons.Length > 0)
                {
                    elm1.Thumbnail = fileIcons[0].ToBitmap().ImageToBase64(System.Drawing.Imaging.ImageFormat.Png);
                    elm1.Name = file.Name;
                    elm1.Executable = @"%systemroot%\system32\" + file.Name;
                    cmdList.Add(elm1);
                }
            }
        }
 private static void AddCmdCommand(SpecialCommandConfigurationElementCollection cmdList)
 {
     cmdList.Add(new SpecialCommandConfigurationElement("Command Shell")
                                                  {
                                                      Executable = @"%systemroot%\system32\cmd.exe"
                                                  });
 }
Esempio n. 6
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            string name = this.shortcutCombobox.Text;
            if (name.Trim() != "" && name.Trim() != "<New...>")
            {
                SpecialCommandConfigurationElement shortcut = this.shortucts[name] ??
                                                              new SpecialCommandConfigurationElement();

                shortcut.Name = name.Trim();
                shortcut.Executable = this.executableTextBox.Text;
                shortcut.WorkingFolder = this.workingFolderTextBox.Text;
                shortcut.Arguments = this.argumentsTextBox.Text;
                string imageName = Path.GetFileName(shortcut.Executable) + ".ico";

                string imageFullName = Path.Combine(AssemblyInfo.DirectoryConfigFiles, imageName);
                if (this.iconPicturebox.Image != null)
                {
                    try
                    {
                        this.iconPicturebox.Image.Save(imageFullName);
                    }
                    catch (Exception exc)
                    {
                        Log.Error("Saving icon picture box failed", exc);
                        imageFullName = "";
                    }
                }
                else
                {
                    imageFullName = "";
                }
                shortcut.Thumbnail = imageFullName;
                this.shortucts.Remove(shortcut);
                this.shortucts.Add(shortcut);

                Settings.SpecialCommands = this.shortucts;
                this.shortucts = Settings.SpecialCommands;
            }
        }
Esempio n. 7
0
 private void deleteButton_Click(object sender, EventArgs e)
 {
     string name = this.shortcutCombobox.Text;
     if (name.Trim() != "" && name.Trim() != "<New...>")
     {
         SpecialCommandConfigurationElement shortcut = this.shortucts[name];
         if (shortcut != null)
         {
             this.shortucts.Remove(shortcut);
             Settings.SpecialCommands = this.shortucts;
             this.shortucts = Settings.SpecialCommands;
         }
     }
     this.LoadShortcuts();
 }