Esempio n. 1
0
        /// <summary>
        /// Registers or unregisters a DLL based on value in first parameter
        /// Inherited from State
        /// </summary>
        /// <param name="register">registers if true, unregisters if not.</param>
        /// <param name="action">Unused param</param>
        public override bool SetValue(Boolean register, object action)
        {
            if (register)
            {
                RegistrationHelper.RegisterComServer(fileName);
            }
            else
            {
                // When unregistering, we need to make sure we're using the same binary
                //  to unregister as the one under the server path (InprocServer32 or LocalServer32)
                RegistryKey inProcServer =
                    Registry.ClassesRoot.OpenSubKey("CLSID").OpenSubKey(clsid).OpenSubKey("InprocServer32");
                RegistryKey localServer =
                    Registry.ClassesRoot.OpenSubKey("CLSID").OpenSubKey(clsid).OpenSubKey("LocalServer32");
                if (inProcServer != null)
                {
                    fileName = (string)inProcServer.GetValue(null);
                }
                else
                {
                    if (localServer != null)
                    {
                        fileName = (string)localServer.GetValue(null);
                    }
                }
                RegistrationHelper.UnregisterComServer(fileName);
            }

            return(true);
        }