示例#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
文件: New.cs 项目: zghnzch/RightMenus
        public new void GetFilePath(List <OneMenu> oneMenuList)
        {
            if (oneMenuList == null || oneMenuList.Count <= 0)
            {
                return;
            }
            foreach (OneMenu oneMenu in oneMenuList)
            {
                try
                {
                    string regPathTemp = oneMenu.RegPath;
                    if (regPathTemp.Contains(MenusLib.BackUpName))
                    {
                        regPathTemp = regPathTemp.Replace("\\New" + MenusLib.BackUpName, "");
                    }
                    string[] namePathArr = regPathTemp.Split('\\');
                    string   regPath     = namePathArr[0] + "\\" + namePathArr[1];
                    string   des         = RegHelper.GetValueData(regPath, "").ToString();
                    oneMenu.Description = des;
                    string rootSid     = RegHelper.GetValueData(regPath, "").ToString();
                    string rootPath    = @"HKEY_CLASSES_ROOT\" + rootSid + @"\shell\open\command";
                    bool   existBranch = RegHelper.ExistBranchName(rootPath);
                    if (existBranch)
                    {
                        string filePath = RegHelper.GetValueData(rootPath, "").ToString();
                        oneMenu.FilePath = filePath;
                    }
                    else
                    {
                    }


                    string defaultIcon     = @"HKEY_CLASSES_ROOT\" + rootSid + @"\DefaultIcon";
                    string defaultIconPath = RegHelper.GetValueData(defaultIcon, "").ToString();
                    oneMenu.DefaultIcon = defaultIconPath;
                }
                catch (Exception)
                {
                }
            }
        }
示例#3
0
        public new void GetFilePath(List <OneMenu> oneMenuList)
        {
            if (oneMenuList == null || oneMenuList.Count <= 0)
            {
                return;
            }
            foreach (OneMenu oneMenu in oneMenuList)
            {
                string   regPath   = oneMenu.RegPath;
                string[] branchArr = RegHelper.GetBranchNames(regPath);

                if (branchArr.Length > 0)
                {
                    foreach (string branch in branchArr)
                    {
                        if (branch.ToLower() == "command".ToLower())
                        {
                            string   valuePath    = regPath + @"\command";
                            string[] valueNameArr = RegHelper.GetValueNames(valuePath);
                            foreach (string value in valueNameArr)
                            {
                                if (value.ToLower() == "DelegateExecute".ToLower())
                                {
                                    string cLSID = RegHelper.GetValueData(valuePath, "DelegateExecute").ToString();
                                    string path  = @"HKEY_CLASSES_ROOT\CLSID\" + cLSID + @"\InProcServer32";
                                    bool   b     = RegHelper.ExistBranchName(path);
                                    if (!b)
                                    {
                                        path = @"HKEY_CLASSES_ROOT\Wow6432Node\CLSID\" + cLSID + @"\InProcServer32";
                                    }
                                    string s = RegHelper.GetValueData(path, "").ToString();
                                    oneMenu.FilePath = s;

                                    string   desPath       = path.Replace(@"\InProcServer32", "");
                                    string[] valueNamesArr = RegHelper.GetValueNames(desPath);
                                    foreach (string valueName in valueNamesArr)
                                    {
                                        if (valueName == string.Empty)
                                        {
                                            oneMenu.Description = RegHelper.GetValueData(desPath, "").ToString();
                                        }
                                    }
                                }
                                if (value == string.Empty)
                                {
                                    string s = RegHelper.GetValueData(valuePath, "").ToString();
                                    oneMenu.FilePath = s;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    string cLSID = RegHelper.GetValueData(regPath, "").ToString();
                    string path  = @"HKEY_CLASSES_ROOT\CLSID\" + cLSID + @"\InProcServer32";
                    bool   b     = RegHelper.ExistBranchName(path);
                    if (!b)
                    {
                        path = @"HKEY_CLASSES_ROOT\Wow6432Node\CLSID\" + cLSID + @"\InProcServer32";
                    }
                    string s = RegHelper.GetValueData(path, "").ToString();
                    oneMenu.FilePath = s;

                    string   desPath       = path.Replace(@"\InProcServer32", "");
                    string[] valueNamesArr = RegHelper.GetValueNames(desPath);
                    foreach (string valueName in valueNamesArr)
                    {
                        if (valueName == string.Empty)
                        {
                            oneMenu.Description = RegHelper.GetValueData(desPath, "").ToString();
                        }
                    }
                }
            }
        }