예제 #1
0
        public void DisplayTask(Microsoft.Win32.TaskScheduler.Task t)
        {
            ComputerProgram program = new ComputerProgram();

            program.ProgramName   = t.Name;
            program.Publisher     = t.Definition.RegistrationInfo.Author;
            program.IsEnabled     = t.Enabled;
            program.RegistryKey   = "Task";
            program.IsEnabledText = (t.Enabled == true ? "Enabled" : "Disabled");
            program.LauncherFile  = t.Definition.Actions.ToString();

            if (t.Definition.Principal.UserId != null && t.Definition.Principal.UserId.ToLower() == "system")
            {
                Tasks.Add(program);
            }
        }
예제 #2
0
        public List <ComputerProgram> GetStartupPrograms()
        {
            List <ComputerProgram> programs = new List <ComputerProgram>();
            RegistryKey            key      = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
            var keys1 = key.GetValueNames();

            foreach (var ky in keys1)
            {
                var path = key.GetValue(ky);

                ComputerProgram program = new ComputerProgram();
                program.ProgramName   = ky;
                program.LauncherFile  = path.ToString();
                program.RegistryKey   = "HKLM:Run";
                program.Publisher     = GetProgramPublisher(program.ProgramName);
                program.IsEnabled     = IsStartupProgramEnabled(program.ProgramName);
                program.IsEnabledText = (program.IsEnabled == true ? "Enabled" : "Disabled");
                programs.Add(program);
            }

            key.Close();


            RegistryKey keyUser       = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
            var         keyUserValues = keyUser.GetValueNames();

            foreach (var ky in keyUserValues)
            {
                var path = keyUser.GetValue(ky);

                ComputerProgram program = new ComputerProgram();
                program.ProgramName  = ky;
                program.LauncherFile = path.ToString();
                program.RegistryKey  = "HKCU:Run";

                program.Publisher     = GetProgramPublisher(program.ProgramName);
                program.IsEnabled     = IsStartupProgramEnabled(program.ProgramName);
                program.IsEnabledText = (program.IsEnabled == true ? "Enabled" : "Disabled");
                programs.Add(program);
            }

            keyUser.Close();



            return(programs);
        }
예제 #3
0
        public List <ComputerProgram> GetContextMenuItems()
        {
            string[] ExludedItems           = { " FileSyncEx", "EPP", "ModernSharing", "Open With", "Sharing", "WorkFolders", "Library Location", "Offline Files", "PintoStartScreen" };
            List <ComputerProgram> programs = new List <ComputerProgram>();

            string filesRegistry     = @"*\shellex\ContextMenuHandlers";
            string foldersRegistry   = @"Folder\shellex\ContextMenuHandlers";
            string directoryRegistry = @"Directory\shellex\ContextMenuHandlers";

            using (var regKey = Registry.ClassesRoot.OpenSubKey(filesRegistry))
            {
                var items = regKey.GetSubKeyNames();
                foreach (string item in items)
                {
                    if (!ExludedItems.Contains(item) && !item.StartsWith("{"))
                    {
                        var             subKey          = regKey.OpenSubKey(item);
                        ComputerProgram contextMenuItem = new ComputerProgram();
                        contextMenuItem.ProgramName = Path.GetFileName(subKey.Name);
                        contextMenuItem.Level       = "File";
                        contextMenuItem.RegistryKey = filesRegistry;

                        if (subKey.GetValue("") != null && !string.IsNullOrEmpty(subKey.GetValue("").ToString()))
                        {
                            if (!subKey.GetValue("").ToString().StartsWith("[CC]"))
                            {
                                contextMenuItem.IsEnabled     = true;
                                contextMenuItem.IsEnabledText = "Enabled";
                            }
                            else
                            {
                                contextMenuItem.IsEnabled     = false;
                                contextMenuItem.IsEnabledText = "Disabled";
                            }


                            programs.Add(contextMenuItem);
                        }
                    }
                }
            }

            using (var regKey = Registry.ClassesRoot.OpenSubKey(foldersRegistry))
            {
                var items = regKey.GetSubKeyNames();
                foreach (string item in items)
                {
                    if (!ExludedItems.Contains(item) && !item.StartsWith("{"))
                    {
                        var             subKey          = regKey.OpenSubKey(item);
                        ComputerProgram contextMenuItem = new ComputerProgram();
                        contextMenuItem.ProgramName = Path.GetFileName(subKey.Name);
                        contextMenuItem.Level       = "Folder";
                        contextMenuItem.RegistryKey = foldersRegistry;

                        if (subKey.GetValue("") != null && !string.IsNullOrEmpty(subKey.GetValue("").ToString()))
                        {
                            if (!subKey.GetValue("").ToString().StartsWith("[CC]"))
                            {
                                contextMenuItem.IsEnabled     = true;
                                contextMenuItem.IsEnabledText = "Enabled";
                            }
                            else
                            {
                                contextMenuItem.IsEnabled     = false;
                                contextMenuItem.IsEnabledText = "Disabled";
                            }


                            programs.Add(contextMenuItem);
                        }


                        programs.Add(contextMenuItem);
                    }
                }
            }

            using (var regKey = Registry.ClassesRoot.OpenSubKey(directoryRegistry))
            {
                var items = regKey.GetSubKeyNames();
                foreach (string item in items)
                {
                    if (!ExludedItems.Contains(item) && !item.StartsWith("{"))
                    {
                        var             subKey          = regKey.OpenSubKey(item);
                        ComputerProgram contextMenuItem = new ComputerProgram();
                        contextMenuItem.ProgramName = Path.GetFileName(subKey.Name);
                        contextMenuItem.Level       = "Directory";
                        contextMenuItem.RegistryKey = directoryRegistry;

                        if (subKey.GetValue("") != null && !string.IsNullOrEmpty(subKey.GetValue("").ToString()))
                        {
                            if (!subKey.GetValue("").ToString().StartsWith("[CC]"))
                            {
                                contextMenuItem.IsEnabled     = true;
                                contextMenuItem.IsEnabledText = "Enabled";
                            }
                            else
                            {
                                contextMenuItem.IsEnabled     = false;
                                contextMenuItem.IsEnabledText = "Disabled";
                            }


                            programs.Add(contextMenuItem);
                        }


                        programs.Add(contextMenuItem);
                    }
                }
            }


            return(programs);
        }