示例#1
0
        private static SpecialCommandConfigurationElement CreateRegEditCommand()
        {
            const string REG_EDIT_EXE = "regedt32.exe";
            string       regEditFile  = Path.Combine(SystemRoot.FullName, REG_EDIT_EXE);

            Icon[] regeditIcons = IconHandler.IconHandler.IconsFromFile(regEditFile, IconHandler.IconSize.Small);
            var    command      = new SpecialCommandConfigurationElement("Registry Editor");

            if (regeditIcons != null && regeditIcons.Length > 0)
            {
                FileLocations.EnsureImagesDirectory();
                string thumbName = FileLocations.FormatThumbFileName(REG_EDIT_EXE);
                SaveIcon(regeditIcons[0], thumbName);
                command.Thumbnail = thumbName;
            }

            command.Executable = regEditFile;
            return(command);
        }
示例#2
0
        private static void AddMmcCommands(SpecialCommandConfigurationElementCollection commands)
        {
            Icon[] iconsList = IconHandler.IconHandler.IconsFromFile(Path.Combine(SystemRoot.FullName, "mmc.exe"),
                                                                     IconHandler.IconSize.Small);
            Random rnd = new Random();

            FileLocations.EnsureImagesDirectory();

            foreach (FileInfo file in SystemRoot.GetFiles("*.msc"))
            {
                MMC.MMCFile fileMMC = new MMC.MMCFile(file);
                var         command = new SpecialCommandConfigurationElement(file.Name);

                if (iconsList != null && iconsList.Length > 0)
                {
                    string thumbName = FileLocations.FormatThumbFileName(file.Name);
                    command.Thumbnail = thumbName;

                    if (fileMMC.SmallIcon != null)
                    {
                        SaveIcon(fileMMC.SmallIcon, thumbName);
                    }
                    else
                    {
                        SaveIcon(iconsList[rnd.Next(iconsList.Length - 1)], thumbName);
                    }

                    if (fileMMC.Parsed)
                    {
                        command.Name = fileMMC.Name;
                    }
                    else
                    {
                        command.Name = file.Name.Replace(file.Extension, "");
                    }
                }

                command.Executable = @"%systemroot%\system32\" + file.Name;
                commands.Add(command);
            }
        }