public static void Register(Type t) { string guid = t.GUID.ToString("B"); RegistryKey rkClass = Registry.ClassesRoot.CreateSubKey(@"CLSID\" + guid); RegistryKey rkCat = rkClass.CreateSubKey("Implemented Categories"); BandObjectAttribute[] boa = (BandObjectAttribute[])t.GetCustomAttributes( typeof(BandObjectAttribute), false); string name = t.Name; string help = t.Name; BandObjectStyle style = 0; if (boa.Length == 1) { if (boa[0].Name != null) { name = boa[0].Name; } if (boa[0].HelpText != null) { help = boa[0].HelpText; } style = boa[0].Style; } rkClass.SetValue(null, name); rkClass.SetValue("MenuText", name); rkClass.SetValue("HelpText", help); if (0 != (style & BandObjectStyle.Vertical)) { rkCat.CreateSubKey("{00021493-0000-0000-C000-000000000046}"); } if (0 != (style & BandObjectStyle.Horizontal)) { rkCat.CreateSubKey("{00021494-0000-0000-C000-000000000046}"); } if (0 != (style & BandObjectStyle.TaskbarToolBar)) { rkCat.CreateSubKey("{00021492-0000-0000-C000-000000000046}"); } if (0 != (style & BandObjectStyle.ExplorerToolbar)) { Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Toolbar").SetValue(guid, name); } }
public static void Unregister(Type t) { string guid = t.GUID.ToString("B"); BandObjectAttribute[] boa = (BandObjectAttribute[])t.GetCustomAttributes(typeof(BandObjectAttribute), false); BandObjectStyle style = 0; if (boa.Length == 1) { style = boa[0].Style; } if (0 != (style & BandObjectStyle.ExplorerToolbar)) { Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Toolbar").DeleteValue(guid, false); } Registry.ClassesRoot.CreateSubKey(@"CLSID").DeleteSubKeyTree(guid); }
public BandObjectAttribute(string name, BandObjectStyle style) { Name = name; Style = style; }
public BandObjectAttribute(string name, string helpText, BandObjectStyle style) { this.Name = name; this.HelpText = helpText; this.BandObjectStyle = style; }
public BandObjectAttribute(string name, BandObjectStyle style) : this(name, name, style) { }
public BandObjectAttribute(string name, BandObjectStyle style) { Name = name; Style = style; }