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);
            }
        }
Esempio n. 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);
            }
        }
        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);
            }
        }