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); }
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); }
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(); } } } } }