コード例 #1
0
            public static ImplementationInterface GetInterface(string guid)
            {
                ImplementationInterface result = new ImplementationInterface();

                result.Guid = guid;
                if (result.Guid == null)
                {
                    return(null);
                }
                result.Name = RegistryManipulator.GetKeyDefaultValue("HKEY_CLASSES_ROOT\\Interface\\" + guid);
                if (result.Name == null)
                {
                    return(null);
                }
                result.ProxyStubClsid32 = RegistryManipulator.GetKeyDefaultValue("HKEY_CLASSES_ROOT\\Interface\\" + guid + "\\ProxyStubClsid32");
                if (result.ProxyStubClsid32 == null)
                {
                    return(null);
                }
                result.TypeLib = RegistryManipulator.GetKeyDefaultValue("HKEY_CLASSES_ROOT\\Interface\\" + guid + "\\TypeLib");
                if (result.TypeLib == null)
                {
                    return(null);
                }
                result.TypeLibVersion = RegistryManipulator.GetStringValue("HKEY_CLASSES_ROOT\\Interface\\" + guid + "\\TypeLib", "Version");
                if (result.TypeLibVersion == null)
                {
                    return(null);
                }

                //success
                return(result);
            }
コード例 #2
0
            public static bool ExportComponentRegistry(string className, string filePath)
            {
                byte[] bytes = null;

                if (!RegistryManipulator.HasClass(className))
                {
                    return(false);
                }

                // className
                RegistryManipulator.ExportKey("HKEY_CLASSES_ROOT\\" + className, ref bytes);

                // CurVer
                string CurVer = GetClassCurVer(className);

                AppendComponentRegistry("HKEY_CLASSES_ROOT\\" + CurVer, ref bytes);

                // AppID
                string componentFilePath = QueryManager.GetComponentFilePath(className);

                if (componentFilePath != null)
                {
                    string execFilename = Path.GetFileName(componentFilePath);
                    string appid        = RegistryManipulator.GetStringValue("HKEY_CLASSES_ROOT\\AppID\\" + execFilename, "AppID");
                    if (appid != null)
                    {
                        AppendComponentRegistry("HKEY_CLASSES_ROOT\\AppID\\" + execFilename, ref bytes);
                        AppendComponentRegistry("HKEY_CLASSES_ROOT\\AppID\\" + appid, ref bytes);
                        AppendComponentRegistry("HKEY_CLASSES_ROOT\\Wow6432Node\\AppID\\" + execFilename, ref bytes);
                        AppendComponentRegistry("HKEY_CLASSES_ROOT\\Wow6432Node\\AppID\\" + appid, ref bytes);
                    }
                }

                // CLSID
                string CurVerCLSID = GetClassID(CurVer);

                AppendComponentRegistry("HKEY_CLASSES_ROOT\\Wow6432Node\\CLSID\\" + CurVerCLSID, ref bytes);

                // TypeLib
                string typelib = RegistryManipulator.GetKeyDefaultValue("HKEY_CLASSES_ROOT\\Wow6432Node\\CLSID\\" + CurVerCLSID + "\\TypeLib");

                if (typelib != null)
                {
                    AppendComponentRegistry("HKEY_CLASSES_ROOT\\TypeLib\\" + typelib, ref bytes);
                    AppendComponentRegistry("HKEY_CLASSES_ROOT\\Wow6432Node\\TypeLib\\" + typelib, ref bytes);

                    // interface
                    string[] interfaces = GetTypeLibInterfaces(typelib);
                    foreach (string interfaceGuid in interfaces)
                    {
                        AppendComponentRegistry("HKEY_CLASSES_ROOT\\Interface\\" + interfaceGuid, ref bytes);
                    }
                }

                //write to output file
                File.WriteAllBytes(filePath, bytes);

                return(true);
            }
コード例 #3
0
        public void GetStringValueTest()
        {
            string keyName   = "HKEY_CLASSES_ROOT\\.txt";
            string valueName = "Content Type";
            string expected  = "text/plain";
            string actual;

            actual = RegistryManipulator.GetStringValue(keyName, valueName);
            Assert.AreEqual(expected, actual);
        }