public void GetSubKeysTest() { string keyName = "HKEY_LOCAL_MACHINE\\HARDWARE"; string[] expected = new string[] { "ACPI", "DESCRIPTION", "DEVICEMAP", "RESOURCEMAP" }; string[] actual; actual = RegistryManipulator.GetSubKeys(keyName); CollectionAssert.AreEqual(expected, actual); }
public static TypeLib GetTypeLib(string guid, string version) { TypeLib result = new TypeLib(); result.Guid = guid; if (result.Guid == null) { return(null); } result.Name = RegistryManipulator.GetKeyDefaultValue("HKEY_CLASSES_ROOT\\Wow6432Node\\TypeLib\\" + guid + "\\" + version); if (result.Name == null) { return(null); } result.Win32Path = RegistryManipulator.GetKeyDefaultValue("HKEY_CLASSES_ROOT\\Wow6432Node\\TypeLib\\" + guid + "\\" + version + "\\0\\win32"); if (result.Win32Path == null) { //sub key under version may be something different than "0". string[] subVersions = RegistryManipulator.GetSubKeys("HKEY_CLASSES_ROOT\\Wow6432Node\\TypeLib\\" + guid + "\\" + version); if (subVersions.Length == 0) { return(null); } string firstSubVersion = subVersions[0]; result.Win32Path = RegistryManipulator.GetKeyDefaultValue("HKEY_CLASSES_ROOT\\Wow6432Node\\TypeLib\\" + guid + "\\" + version + "\\" + firstSubVersion + "\\win32"); if (result.Win32Path == null) { return(null); //failed } } result.Flags = RegistryManipulator.GetKeyDefaultValue("HKEY_CLASSES_ROOT\\Wow6432Node\\TypeLib\\" + guid + "\\" + version + "\\FLAGS"); if (result.Flags == null) { return(null); } result.HelpDir = RegistryManipulator.GetKeyDefaultValue("HKEY_CLASSES_ROOT\\Wow6432Node\\TypeLib\\" + guid + "\\" + version + "\\HELPDIR"); if (result.HelpDir == null) { return(null); } //success return(result); }
public static string[] GetTypeLibInterfaces(string guid) { var typelibInterfaces = new List <string>(); //get all interfaces of the system string[] interfaces = RegistryManipulator.GetSubKeys("HKEY_CLASSES_ROOT\\Interface"); //for each interfaces foreach (string interfaceGuid in interfaces) { string interfaceTypeLib = RegistryManipulator.GetKeyDefaultValue("HKEY_CLASSES_ROOT\\Interface\\" + interfaceGuid + "\\TypeLib"); if (guid.Equals(interfaceTypeLib)) { typelibInterfaces.Add(interfaceGuid); } } return(typelibInterfaces.ToArray()); }