コード例 #1
0
ファイル: New.cs プロジェクト: zghnzch/RightMenus
        public List <OneMenu> GetMenuList()
        {
            //读取缓存区域
            string sourcePath = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\ShellNew";

            string[]       sourceNameArr     = (string[])RegHelper.GetValueData(sourcePath, "Classes");
            List <OneMenu> sourceOneMenuList = new List <OneMenu>();

            foreach (string name in sourceNameArr)
            {
                string path         = "HKEY_CLASSES_ROOT" + @"\" + name;
                string shellNewPath = string.Empty;
                bool   keyExist     = RegHelper.ExistBranchName(path, "ShellNew", out shellNewPath);
                if (keyExist)
                {
                    OneMenu oneMenu = new OneMenu();
                    if (!path.Contains(MenusLib.BackUpName))
                    {
                        oneMenu.Checked = true;
                    }
                    oneMenu.RegPath = shellNewPath;
                    oneMenu.Name    = name;
                    sourceOneMenuList.Add(oneMenu);
                }
            }

            string sourcePath2 = "HKEY_CLASSES_ROOT" + @"\New" + MenusLib.BackUpName;

            string[] backupNameArr = RegHelper.GetBranchNames(sourcePath2);

            List <OneMenu> sourceOneMenuList2 = new List <OneMenu>();

            if (backupNameArr != null)
            {
                foreach (string name in backupNameArr)
                {
                    string path         = sourcePath2 + "\\" + name;
                    string shellNewPath = string.Empty;
                    bool   keyExist     = RegHelper.ExistBranchName(path, "ShellNew", out shellNewPath);

                    if (keyExist)
                    {
                        OneMenu oneMenu = new OneMenu();
                        oneMenu.RegPath = shellNewPath;
                        oneMenu.Name    = name;
                        sourceOneMenuList2.Add(oneMenu);
                    }
                }
            }

            List <OneMenu> oneMenuList = sourceOneMenuList.AddOneMenuList(sourceOneMenuList2);

            GetFilePath(oneMenuList);
            GetVersionInfo(oneMenuList);
            return(oneMenuList);
        }
コード例 #2
0
ファイル: SendTo.cs プロジェクト: zghnzch/RightMenus
        public List <OneMenu> GetMenuList()
        {
            //string[] strArr = new[]
            //{
            //    @"HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell"
            //};

            List <OneMenu> oneMenuList = new List <OneMenu>(); //= GetMenuList(strArr)

            if (Directory.Exists(_sendToSource))
            {
                var files = Directory.GetFiles(_sendToSource, "*.*");
                foreach (var file in files)
                {
                    OneMenu oneMenu = new OneMenu();
                    oneMenu.Checked  = true;
                    oneMenu.FileName = MenusLib.GetFileName(file);

                    oneMenu.Name     = MenusLib.GetFileName(file);
                    oneMenu.FilePath = GetFilePath(file);
                    oneMenu.RegPath  = file;
                    oneMenuList.Add(oneMenu);
                }
            }
            if (Directory.Exists(_sendToBackup))
            {
                var files = Directory.GetFiles(_sendToBackup, "*.*");
                foreach (var file in files)
                {
                    OneMenu oneMenu = new OneMenu();
                    oneMenu.Checked  = false;
                    oneMenu.FileName = MenusLib.GetFileName(file);
                    oneMenu.Name     = MenusLib.GetFileName(file);
                    oneMenu.FilePath = GetFilePath(file);
                    oneMenu.RegPath  = file;

                    oneMenuList.Add(oneMenu);
                }
            }
            else
            {
                Directory.CreateDirectory(_sendToBackup);
            }
            GetVersionInfo(oneMenuList);
            return(oneMenuList);
        }
コード例 #3
0
ファイル: MenusLib.cs プロジェクト: zghnzch/RightMenus
        public static List <OneMenu> GetMenuList(string path)
        {
            string[] nameArr = RegHelper.GetBranchNames(path);
            if (nameArr == null)
            {
                return(null);
            }
            List <OneMenu> oneMenuList = new List <OneMenu>();

            foreach (string name in nameArr)
            {
                OneMenu oneMenu = new OneMenu();
                if (!path.Contains(MenusLib.BackUpName))
                {
                    oneMenu.Checked = true;
                }
                oneMenu.RegPath = path + "\\" + name;
                oneMenu.Name    = name;
                oneMenuList.Add(oneMenu);
            }
            return(oneMenuList);
        }