void InsertUnitsFromAssembly(System.Reflection.Assembly assembly)
 {
     Type[] types = assembly.GetExportedTypes();
     foreach (Type type in types)
     {
         if (typeof(CapeOpen.ICapeUnit).IsAssignableFrom(type) && !type.IsAbstract &&
             type != typeof(UnitOperationWrapper))
         {
             UnitOperationInformation unit = new UnitOperationInformation();
             object[] attributes           = type.GetCustomAttributes(true);
             for (int i = 0; i < attributes.Length; i++)
             {
                 if (attributes[i] is CapeNameAttribute)
                 {
                     unit.Name = ((CapeNameAttribute)attributes[i]).Name;
                 }
                 if (attributes[i] is CapeDescriptionAttribute)
                 {
                     unit.Description = ((CapeDescriptionAttribute)attributes[i]).Description;
                 }
                 if (attributes[i] is CapeVersionAttribute)
                 {
                     unit.CapeVersion = ((CapeVersionAttribute)attributes[i]).Version;
                 }
                 if (attributes[i] is CapeVendorURLAttribute)
                 {
                     unit.VendorURL = ((CapeVendorURLAttribute)attributes[i]).VendorURL;
                 }
                 if (attributes[i] is CapeHelpURLAttribute)
                 {
                     unit.HelpURL = ((CapeHelpURLAttribute)attributes[i]).HelpURL;
                 }
                 if (attributes[i] is CapeAboutAttribute)
                 {
                     unit.About = ((CapeAboutAttribute)attributes[i]).About;
                 }
                 unit.ProgID   = type.FullName;
                 unit.Assembly = assembly.FullName;
             }
             unit.Type = type;
             m_UnitOperations.Add(unit);
             m_DotNetUnitOperations.Add(unit);
         }
     }
 }
        void InsertAvailableCOM()
        {
            //initialize namespace Controls Category namespace Controlsds
            // CAPE-OPEN Category - namespace ControlsComponent_CATID
            String rgcid5;

            //rgcid1 = "";//{678c09a1-7d66-11d2-a67d-00105a42887f}";
            // External CAPE-OPEN Thermo Routines - CapeExternalThermoRoutine_CATID
            //rgcid2 = "";//{678c09a2-7d66-11d2-a67d-00105a42887f}";
            // CAPE-OPEN Thermo System - CapeThermoSystem_CATID
            //rgcid3 = "";//{678c09a3-7d66-11d2-a67d-00105a42887f}";
            // CAPE-OPEN Thermo Property Package - CapeThermoPropertyPackage_CATID
            //rgcid4 = "";//{678c09a4-7d66-11d2-a67d-00105a42887f}";
            // CAPE-OPEN Unit Operation - CapeUnitOperation_CATID
            rgcid5 = "{678c09a5-7d66-11d2-a67d-00105a42887f}";
            // CAPE-OPEN Thermo Equilibrium Server - CapeThermoEquilibriumServer_CATID
            //rgcid6 = "";//{678c09a6-7d66-11d2-a67d-00105a42887f}";

            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("CLSID");
            // get the classes that implement the various Cape Open categories
            // CapeUnit category
            String[] sknames = key.GetSubKeyNames();
            key.Close();
            for (int n = 0; n < sknames.Length; n++)
            {
                key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(String.Concat("CLSID\\", sknames[n]));
                String[]    subnames = key.GetSubKeyNames();
                bool        found    = false;
                String      name     = null;//, image = null;
                Type        type     = null;
                System.Guid CLSID    = System.Guid.Empty;
                //System.Drawing.Bitmap bitty = null;
                for (int i = 0; i < subnames.Length; i++)
                {
                    if (subnames[i] == "Implemented Categories")
                    {
                        Microsoft.Win32.RegistryKey subkey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("CLSID\\" + sknames[n] + "\\Implemented Categories");
                        String[] vals = subkey.GetSubKeyNames();
                        for (int z = 0; z < vals.Length; z++)
                        {
                            if (String.Compare(vals[z], rgcid5, true) == 0)
                            {
                                found = true;
                            }
                        }
                        subkey.Close();
                    }
                    else if (String.Compare(subnames[i], "progid", true) == 0 && found == true)
                    {
                        Microsoft.Win32.RegistryKey subkey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(String.Concat("CLSID\\", sknames[n], "\\ProgID"));
                        String[] vals = subkey.GetValueNames();
                        if (vals.Length >= 1)
                        {
                            name  = (String)(subkey.GetValue(vals[0], typeof(String)));
                            CLSID = new System.Guid(sknames[n]);
                            type  = Type.GetTypeFromCLSID(CLSID);
                        }
                        subkey.Close();
                        Microsoft.Win32.RegistryKey descriptionKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(String.Concat("CLSID\\", sknames[n], "\\CapeDescription"));
                        if (descriptionKey != null && !typeof(CapeUnitBase).IsAssignableFrom(type) && CLSID != new System.Guid("48c6795c-a67d-4807-8881-c4c9e02418d0"))
                        {
                            UnitOperationInformation unit = new UnitOperationInformation();
                            String[] descriptions         = descriptionKey.GetValueNames();
                            unit.Name             = descriptionKey.GetValue("Name", String.Empty).ToString();
                            unit.Description      = descriptionKey.GetValue("Description", String.Empty).ToString();
                            unit.CapeVersion      = descriptionKey.GetValue("CapeVersion", String.Empty).ToString();
                            unit.ComponentVersion = descriptionKey.GetValue("ComponentVersion", String.Empty).ToString();
                            unit.VendorURL        = descriptionKey.GetValue("VendorURL", String.Empty).ToString();
                            unit.HelpURL          = descriptionKey.GetValue("HelpURL", String.Empty).ToString();
                            unit.About            = descriptionKey.GetValue("About", String.Empty).ToString();
                            unit.Type             = type;
                            unit.ProgID           = name;
                            unit.CLSID            = CLSID;
                            unit.Assembly         = "";
                            m_UnitOperations.Add(unit);
                            m_ComBasedUnitOperations.Add(unit);
                            descriptionKey.Close();
                        }
                        else
                        {
                            //infos.Add(null);
                        }
                    }
                    //else if (found == true) //&& ((subnames[i].CompareTo("ToolboxBitmap32") == 0) ||	subnames[i].CompareTo("DefaultIcon")))
                    //{
                    //    Microsoft.Win32.RegistryKey subkey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(String.Concat("CLSID\\", sknames[n], "\\ToolboxBitmap32"));
                    //    string[] vals = subkey.GetValueNames();
                    //    if (vals.Length >= 1)
                    //    {
                    //        image = (String)(subkey.GetValue(vals[0], typeof(String)));
                    //        int pos = image.IndexOf(",");
                    //        if (pos == -1)
                    //        {
                    //            System.Drawing.Icon ic = null;// System::Drawing::Icon::FromHandle(ExtractIcon(System::Diagnostics::Process::GetCurrentProcess()->Handle,image,0));
                    //            bitty = ic.ToBitmap();
                    //        }
                    //        else
                    //        {
                    //            /*						first = image->Substring(0,pos);
                    //            second = image->Substring(pos+1);
                    //            IntPtr ptr = System::Diagnostics::Process::GetCurrentProcess()->Handle;
                    //            UInt32 hic = ExtractIcon(ptr,first,Convert::ToUInt32(second));
                    //            if(hic ==0)
                    //            bitty = gcnew Bitmap(imageList2->Images[0]);
                    //            else
                    //            {
                    //            System::Drawing::Icon^ ic = System::Drawing::Icon::FromHandle(IntPtr(hic));
                    //            bitty = ic->ToBitmap();
                    //            }
                    //            */
                    //        }
                    //    }
                    //    subkey.Close();
                    //}
                }
                if (found == true && name != null)
                {
                    //if(!listBox1.Items.Contains(new ListViewItem(name)))
                    //{
                    //    listBox1.Items.Add(name);
                    //    if(bitty == nullptr)
                    //        bitty = gcnew Bitmap(imageList2.Images[0]);
                    //    imageList1.Images.Add(bitty);
                    //    ToolStripButton button = new ToolStripButton(name, bitty);
                    //    this.toolStrip1.Items.Add(button);
                    //    button.Visible = true;
                    //    button.Tag = type;
                    //    button.DisplayStyle = ToolStripItemDisplayStyle.Image;
                    //}
                }
                key.Close();
            }
        }