home *** CD-ROM | disk | FTP | other *** search
- // Pavel Zolnikov[http://www.codeproject.com/script/profile/whos_who.asp?id=35980], 2002
-
- using System;
- using System.Collections;
- using System.Windows.Forms;
- using System.ComponentModel;
- using System.Configuration.Install;
- using System.Runtime.InteropServices;
- using System.Reflection;
- using Microsoft.Win32;
- using Shell32;
- using SHDocVw;
- using System.Diagnostics;
-
- namespace CommandBar
- {
- /// <summary>
- /// Summary description for Installer.
- /// </summary>
- [RunInstaller(true)]
- public class Installer : System.Configuration.Install.Installer
- {
- public override void Uninstall(System.Collections.IDictionary savedState)
- {
- base.Uninstall(savedState);
- RegistrationServices rs = new RegistrationServices();
- rs.UnregisterAssembly( CommandBarAssembly );
-
- InvalidateExplorerBarsList();
- }
-
- public static void Main()
- {
- // ShellWindowsClass windows = new ShellWindowsClass();
- //
- // foreach( Object w in windows )
- // {
- // ShellBrowserWindow folderView = w as ShellBrowserWindow;
- // if( folderView != null )
- // {
- // MessageBox.Show(folderView.LocationURL);
- // }
- // }
- }
-
-
- Assembly CommandBarAssembly
- {
- get
- {
- return AppDomain.CurrentDomain.Load("CommandBar, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f62fe54d9a592d72, Custom=null");
- }
- }
-
- protected override void OnCommitted(System.Collections.IDictionary savedState)
- {
- base.OnCommitted(savedState);
-
- RegistrationServices rs = new RegistrationServices();
- rs.RegisterAssembly(
- CommandBarAssembly,
- AssemblyRegistrationFlags.None
- );
-
- InvalidateExplorerBarsList();
- }
-
- //invalidating list of explorer bars
- //Special thanks to Michael Dunn[http://www.codeproject.com/script/profile/whos_who.asp?id=152] for the tip.
- protected void InvalidateExplorerBarsList()
- {
- try
- {
- RegistryKey categories = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\Component Categories",true);
- categories.OpenSubKey("{00021493-0000-0000-C000-000000000046}",true).DeleteSubKey("Enum",false);
- categories.OpenSubKey("{00021494-0000-0000-C000-000000000046}",true).DeleteSubKey("Enum",false);
- }
- catch( Exception e )
- {
- #if DEBUG
- MessageBox.Show( e.ToString() );
- throw;
- #endif
- }
- }
- }
- }
-