private void CreateRegistryEntries(Assembly addinAssembly, IEnumerable<object> assemblyAttributes, SingletonSettings.RegisterMode mode, Type addinClassType, IEnumerable<object> addinClassAttributes) { AddinClassInformations addinClass = AddinClassInformations.Create( addinAssembly, assemblyAttributes, mode, addinClassType, addinClassAttributes); Registry registry = new Registry(); Microsoft.Win32.RegistryKey key = registry.CreateComponentKey(Settings.Mode, addinClass.ProgId); registry.CreateComponentValue(key, "", addinClass.FullClassName, Microsoft.Win32.RegistryValueKind.String); key.Close(); key = registry.CreateComponentKey(Settings.Mode, String.Format("{0}\\CLSID", addinClass.ProgId)); registry.CreateComponentValue(key, "", "{" + addinClass.Id.ToString() + "}", Microsoft.Win32.RegistryValueKind.String); key.Close(); key = registry.CreateComponentKey(Settings.Mode, "CLSID\\{" + addinClass.Id + "}"); registry.CreateComponentValue(key, "", addinClass.FullClassName, Microsoft.Win32.RegistryValueKind.String); key.Close(); key = registry.CreateComponentKey(Settings.Mode, "CLSID\\{" + addinClass.Id + "}\\InprocServer32"); registry.CreateComponentValue(key, "", "mscoree.dll", Microsoft.Win32.RegistryValueKind.String); registry.CreateComponentValue(key, "ThreadingModel", "Both", Microsoft.Win32.RegistryValueKind.String); registry.CreateComponentValue(key, "Class", addinClass.FullClassName, Microsoft.Win32.RegistryValueKind.String); registry.CreateComponentValue(key, "Assembly", String.Format("{0}, Version={1}, Culture={2}, PublicKeyToken={3}", addinClass.AssemblyName, addinClass.AssemblyVersion, addinClass.AssemblyCulture, addinClass.AssemblyToken), Microsoft.Win32.RegistryValueKind.String); registry.CreateComponentValue(key, "RuntimeVersion", addinClass.RuntimeVersion, Microsoft.Win32.RegistryValueKind.String); if (Settings.Codebase) registry.CreateComponentValue(key, "Codebase", addinClass.Codebase, Microsoft.Win32.RegistryValueKind.String); key.Close(); key = registry.CreateComponentKey(Settings.Mode, "CLSID\\{" + addinClass.Id + "}\\InprocServer32\\" + addinClass.AssemblyVersion); registry.CreateComponentValue(key, "Class", addinClass.FullClassName, Microsoft.Win32.RegistryValueKind.String); registry.CreateComponentValue(key, "Assembly", String.Format("{0}, Version={1}, Culture={2}, PublicKeyToken={3}", addinClass.AssemblyName, addinClass.AssemblyVersion, addinClass.AssemblyCulture, addinClass.AssemblyToken), Microsoft.Win32.RegistryValueKind.String); registry.CreateComponentValue(key, "RuntimeVersion", addinClass.RuntimeVersion, Microsoft.Win32.RegistryValueKind.String); if (Settings.Codebase) registry.CreateComponentValue(key, "Codebase", addinClass.Codebase, Microsoft.Win32.RegistryValueKind.String); key.Close(); key = registry.CreateComponentKey(Settings.Mode, String.Format("CLSID\\{0}\\{1}","{" + addinClass.Id + "}", "ProgId")); registry.CreateComponentValue(key, "", addinClass.ProgId, Microsoft.Win32.RegistryValueKind.String); key.Close(); key = registry.CreateComponentKey(Settings.Mode, String.Format("CLSID\\{0}\\Implemented Categories\\{1}", "{" + addinClass.Id + "}", "{" + addinClass.ComponentCategoryId +"}")); key.Close(); }
private void DeleteRegistryEntries(Assembly addinAssembly, IEnumerable<object> assemblyAttributes, SingletonSettings.UnRegisterMode mode, Type addinClassType, IEnumerable<object> addinClassAttributes) { AddinClassInformations addinClass = AddinClassInformations.Create( addinAssembly, assemblyAttributes, mode, addinClassType, addinClassAttributes); Registry registry = new Registry(); registry.DeleteComponentKey(Settings.Mode, addinClass.ProgId); registry.DeleteComponentKey(Settings.Mode, "CLSID\\{" + addinClass.Id + "}"); }