//No validation: Assumes that the path is a valid collection folder containing both a "IndexStore" and "ContentStore" folder private static int AddCollection(string path, List <CatalogItem> catList, String metaName) //Meta name is optional { int iRet = catList.Count; path = path.TrimEnd(new char[] { '\\' }); String CatalogID; if (String.IsNullOrEmpty(metaName)) { CatalogID = path.Substring(path.LastIndexOf("\\") + 1); //last segment of path } else { CatalogID = metaName; } if (Directory.Exists(path)) //it could be an .mshx file { path = path + "\\"; } CatalogItem catItem = new CatalogItem(CatalogID, path); //Add all localeList found under ContentStore String contentsStorePath = Path.Combine(path, "ContentStore\\"); if (Directory.Exists(contentsStorePath)) { var dirs = Directory.EnumerateDirectories(Path.Combine(path, "ContentStore\\")); foreach (var dir in dirs) { String locale = dir.Substring(dir.LastIndexOf("\\") + 1); if ((locale.Length == 5) && (locale[2] == '-')) //Looks like a Locale form eg. "en-US" { catItem.AddLocaleItem(locale, metaName, ""); } } } catList.Add(catItem); return(iRet); }
public static List<CatalogItem> GetCatalogs() { List<CatalogItem> resultList = new List<CatalogItem>(); CatalogItem catalogItem; HV2RegInfo hv2RegInfo = new HV2RegInfo(); RegistryKey baseKeyName = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, hv2RegInfo.RegistryView); if (baseKeyName != null) { //[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.0\Catalogs] RegistryKey subkey = baseKeyName.OpenSubKey(hv2RegInfo.KEY_Help_v20_Catalogs); if (subkey != null) { //[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.0\Catalogs\*] String[] catList = subkey.GetSubKeyNames(); subkey.Close(); foreach (String catalogID in catList) { //eg. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.0\Catalogs\VisualStudio11] String key = hv2RegInfo.KEY_Help_v20_Catalogs + @"\" + catalogID; subkey = baseKeyName.OpenSubKey(key); if (subkey != null) { //eg. LocationPath=C:\ProgramData\Microsoft\HelpLibrary2\Catalogs\VisualStudio11\ String LocationPath = (string)subkey.GetValue("LocationPath"); //Create new recort catalogItem = new CatalogItem(true, catalogID, LocationPath); //true = valud is from the registry //[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.0\Catalogs\VisualStudio11\*] String[] localeList = subkey.GetSubKeyNames(); subkey.Close(); //[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.0\Catalogs\VisualStudio11\en-US] foreach (String locale in localeList) { String localeKey = hv2RegInfo.KEY_Help_v20_Catalogs + @"\" + catalogID + @"\" + locale; subkey = baseKeyName.OpenSubKey(localeKey); if (subkey != null) { //eg. catalogName=Visual Studio 2011 Help Documentation String catalogName = (string)subkey.GetValue("catalogName"); //eg. SeedFilePath=C:\Program Files\Microsoft Help Viewer\v2.0\CatalogInfo\VS11_en-us.cab String SeedFilePath = (string)subkey.GetValue("SeedFilePath"); //Add to results catalogItem.AddLocaleItem(locale, catalogName, SeedFilePath); subkey.Close(); } } //Add to result list resultList.Add(catalogItem); } } } baseKeyName.Close(); } return (resultList); }
//Meta name is optional //No validation: Assumes that the path is a valid collection folder containing both a "IndexStore" and "ContentStore" folder private static int AddCollection(string path, List<CatalogItem> catList, String metaName) { int iRet = catList.Count; path = path.TrimEnd(new char[] { '\\' }); String CatalogID; if (String.IsNullOrEmpty(metaName)) CatalogID = path.Substring(path.LastIndexOf("\\") + 1); //last segment of path else CatalogID = metaName; if (Directory.Exists(path)) //it could be an .mshx file path = path + "\\"; CatalogItem catItem = new CatalogItem(CatalogID, path); //Add all localeList found under ContentStore String contentsStorePath = Path.Combine(path, "ContentStore\\"); if (Directory.Exists(contentsStorePath)) { var dirs = Directory.EnumerateDirectories(Path.Combine(path, "ContentStore\\")); foreach (var dir in dirs) { String locale = dir.Substring(dir.LastIndexOf("\\") + 1); if ((locale.Length == 5) && (locale[2] == '-')) //Looks like a Locale form eg. "en-US" { catItem.AddLocaleItem(locale, metaName, ""); } } } catList.Add(catItem); return iRet; }
public static List <CatalogItem> GetCatalogs() { List <CatalogItem> resultList = new List <CatalogItem>(); CatalogItem catalogItem; HV2RegInfo hv2RegInfo = new HV2RegInfo(); RegistryKey baseKeyName = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, hv2RegInfo.RegistryView); if (baseKeyName != null) { //[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.0\Catalogs] RegistryKey subkey = baseKeyName.OpenSubKey(hv2RegInfo.KEY_Help_v20_Catalogs); if (subkey != null) { //[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.0\Catalogs\*] String[] catList = subkey.GetSubKeyNames(); subkey.Close(); foreach (String catalogID in catList) { //eg. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.0\Catalogs\VisualStudio11] String key = hv2RegInfo.KEY_Help_v20_Catalogs + @"\" + catalogID; subkey = baseKeyName.OpenSubKey(key); if (subkey != null) { //eg. LocationPath=C:\ProgramData\Microsoft\HelpLibrary2\Catalogs\VisualStudio11\ String LocationPath = (string)subkey.GetValue("LocationPath"); //Create new recort catalogItem = new CatalogItem(true, catalogID, LocationPath); //true = valud is from the registry //[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.0\Catalogs\VisualStudio11\*] String[] localeList = subkey.GetSubKeyNames(); subkey.Close(); //[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Help\v2.0\Catalogs\VisualStudio11\en-US] foreach (String locale in localeList) { String localeKey = hv2RegInfo.KEY_Help_v20_Catalogs + @"\" + catalogID + @"\" + locale; subkey = baseKeyName.OpenSubKey(localeKey); if (subkey != null) { //eg. catalogName=Visual Studio 2011 Help Documentation String catalogName = (string)subkey.GetValue("catalogName"); //eg. SeedFilePath=C:\Program Files\Microsoft Help Viewer\v2.0\CatalogInfo\VS11_en-us.cab String SeedFilePath = (string)subkey.GetValue("SeedFilePath"); //Add to results catalogItem.AddLocaleItem(locale, catalogName, SeedFilePath); subkey.Close(); } } //Add to result list resultList.Add(catalogItem); } } } baseKeyName.Close(); } return(resultList); }