Click here to Skip to main content
15,884,099 members
Articles / Multimedia / GDI+

Pretty IE Toolbar in C#

Rate me:
Please Sign up or sign in to vote.
4.89/5 (39 votes)
9 Sep 2008CPOL5 min read 173.4K   4.8K   121  
The article describes the work principles and ways of use of IEToolbarEngine. This is a toolbar for Internet Explorer, which has a reusable architecture.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Runtime.InteropServices;
using System.Reflection;
using System.IO;
using SHDocVw;
using Microsoft.Win32;

namespace IEToolbarEngine
{
    [RunInstaller (true)]
    public partial class IEToolbarInstaller : Installer
    {
        public IEToolbarInstaller ()
        {
            InitializeComponent ();
        }

        /// <summary>
        /// Installation
        /// </summary>
        public override void Install (System.Collections.IDictionary stateSaver)
        {
            base.Install (stateSaver);
            RegistrationServices regsrv = new RegistrationServices ();
            if (!regsrv.RegisterAssembly (this.GetType ().Assembly,
            AssemblyRegistrationFlags.SetCodeBase))
            {
                throw new InstallException ("Failed To Register for COM");
            }

            IEToolbarEngine.InstallationDate = DateTime.Now;
        }

        /// <summary>
        /// Deinstallation
        /// </summary>
        /// <param name="savedState"></param>
        public override void Uninstall (System.Collections.IDictionary savedState)
        {
            Assembly asm = Assembly.GetExecutingAssembly ();
            string fullName = asm.GetModules () [0].FullyQualifiedName;
            string dataFolder = IEToolbarEngine.DataFolder;
            try
            {
                Directory.Delete (dataFolder, true);
            }
            catch (Exception)
            {
                //System.Windows.Forms.MessageBox.Show (ex.Message);
            }

            try
            {
                Registry.LocalMachine.DeleteSubKeyTree (IEToolbarEngine.AppKey);
                Registry.CurrentUser.DeleteSubKeyTree(IEToolbarEngine.AppKey);
            }
            catch (Exception)
            {
            }

            base.Uninstall (savedState);
            RegistrationServices regsrv = new RegistrationServices ();
            if (!regsrv.UnregisterAssembly (this.GetType ().Assembly))
            {
                throw new InstallException ("Failed To Unregister for COM");
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Russian Federation Russian Federation
Alexandr Golovanov is a .NET developer at KB_Soft Group, an offshore software development company located in Russia, Novosibirsk. Here he has worked
on various .NET projects.

Comments and Discussions