예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
 public BandObjectAttribute(string name, BandObjectStyle style) {
     Name = name;
     Style = style;
 }
예제 #4
0
 public BandObjectAttribute(string name, string helpText, BandObjectStyle style)
 {
     this.Name            = name;
     this.HelpText        = helpText;
     this.BandObjectStyle = style;
 }
예제 #5
0
 public BandObjectAttribute(string name, BandObjectStyle style)
     : this(name, name, style)
 {
 }
예제 #6
0
 public BandObjectAttribute(string name, BandObjectStyle style)
 {
     Name  = name;
     Style = style;
 }