home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2005 November / PCWELT_11_2005.ISO / pcwsoft / Commandbar-Source.z.exe / Setup / Installer / Installer.cs next >
Encoding:
Text File  |  2002-06-10  |  2.3 KB  |  88 lines

  1. // Pavel Zolnikov[http://www.codeproject.com/script/profile/whos_who.asp?id=35980], 2002
  2.  
  3. using System;
  4. using System.Collections;
  5. using System.Windows.Forms;
  6. using System.ComponentModel;
  7. using System.Configuration.Install;
  8. using System.Runtime.InteropServices;
  9. using System.Reflection;
  10. using Microsoft.Win32;
  11. using Shell32;
  12. using SHDocVw;
  13. using System.Diagnostics;
  14.  
  15. namespace CommandBar
  16. {
  17.     /// <summary>
  18.     /// Summary description for Installer.
  19.     /// </summary>
  20.     [RunInstaller(true)]
  21.     public class Installer : System.Configuration.Install.Installer
  22.     {
  23.         public override void Uninstall(System.Collections.IDictionary savedState)
  24.         {
  25.             base.Uninstall(savedState);
  26.             RegistrationServices rs = new RegistrationServices();
  27.             rs.UnregisterAssembly( CommandBarAssembly );
  28.  
  29.             InvalidateExplorerBarsList();
  30.         }
  31.  
  32.         public static void Main()
  33.         {        
  34. //            ShellWindowsClass windows = new ShellWindowsClass();
  35. //
  36. //            foreach( Object w in windows )
  37. //            {
  38. //                ShellBrowserWindow folderView = w as ShellBrowserWindow;
  39. //                if( folderView != null )
  40. //                {
  41. //                    MessageBox.Show(folderView.LocationURL);
  42. //                }
  43. //            }
  44.         }
  45.  
  46.  
  47.         Assembly CommandBarAssembly
  48.         {
  49.             get
  50.             {
  51.                 return AppDomain.CurrentDomain.Load("CommandBar, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f62fe54d9a592d72, Custom=null");
  52.             }
  53.         }
  54.  
  55.         protected override void OnCommitted(System.Collections.IDictionary savedState)
  56.         {
  57.             base.OnCommitted(savedState);
  58.  
  59.             RegistrationServices rs = new RegistrationServices();
  60.             rs.RegisterAssembly( 
  61.                 CommandBarAssembly,
  62.                 AssemblyRegistrationFlags.None
  63.                 );
  64.  
  65.             InvalidateExplorerBarsList();
  66.         }
  67.  
  68.         //invalidating list of explorer bars
  69.         //Special thanks to Michael Dunn[http://www.codeproject.com/script/profile/whos_who.asp?id=152] for the tip.
  70.         protected void     InvalidateExplorerBarsList()
  71.         {
  72.             try
  73.             {
  74.                 RegistryKey categories = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\Component Categories",true);
  75.                 categories.OpenSubKey("{00021493-0000-0000-C000-000000000046}",true).DeleteSubKey("Enum",false);
  76.                 categories.OpenSubKey("{00021494-0000-0000-C000-000000000046}",true).DeleteSubKey("Enum",false);
  77.             }
  78.             catch( Exception e )
  79.             {
  80. #if DEBUG
  81.                 MessageBox.Show( e.ToString() );
  82.                 throw;
  83. #endif
  84.             }
  85.         }
  86.     }
  87. }
  88.