Form to display basic information about an object
Inheritance: System.Windows.Forms.UserControl
Ejemplo n.º 1
0
        private void menuROTBindToObject_Click(object sender, EventArgs e)
        {
            if (listViewROT.SelectedItems.Count != 0)
            {
                MonikerInfo info = (MonikerInfo)(listViewROT.SelectedItems[0].Tag);

                Dictionary <string, string> props = new Dictionary <string, string>();
                props.Add("Display Name", info.strDisplayName);
                props.Add("CLSID", info.clsid.FormatGuid());

                try
                {
                    IBindCtx bindCtx = COMUtilities.CreateBindCtx(0);
                    Guid     unk     = COMInterfaceEntry.IID_IUnknown;
                    object   comObj;
                    Type     dispType;

                    info.moniker.BindToObject(bindCtx, null, ref unk, out comObj);
                    dispType = COMUtilities.GetDispatchTypeInfo(this, comObj);
                    ObjectInformation view = new ObjectInformation(m_registry, null, info.strDisplayName,
                                                                   comObj, props, m_registry.GetInterfacesForObject(comObj));
                    Program.GetMainForm(m_registry).HostControl(view);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task HostObject(ICOMClassEntry ent, object obj, bool factory)
        {
            Dictionary <string, string> props = new Dictionary <string, string>();

            if (ent == null)
            {
                ent = new COMCLSIDEntry(m_registry, Guid.Empty, COMServerType.UnknownServer);
            }
            props.Add("CLSID", ent.Clsid.FormatGuid());
            props.Add("Name", ent.Name);
            props.Add("Server", ent.DefaultServer);

            /* Need to implement a type library reader */
            Type dispType = COMUtilities.GetDispatchTypeInfo(this, obj);

            if (!ent.InterfacesLoaded)
            {
                await ent.LoadSupportedInterfacesAsync(false, null);
            }

            IEnumerable <COMInterfaceInstance> intfs = factory ? ent.FactoryInterfaces : ent.Interfaces;

            ObjectInformation view = new ObjectInformation(m_registry, ent, ent.Name, obj,
                                                           props, intfs.Select(i => m_registry.MapIidToInterface(i.Iid)).ToArray());

            HostControl(view);
        }
Ejemplo n.º 3
0
        private async void createInstanceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = treeComRegistry.SelectedNode;

            if (node != null)
            {
                COMCLSIDEntry ent = null;
                if (node.Tag is COMCLSIDEntry)
                {
                    ent = (COMCLSIDEntry)node.Tag;
                }
                else if (node.Tag is COMProgIDEntry)
                {
                    ent = m_reg.MapClsidToEntry(((COMProgIDEntry)node.Tag).Clsid);
                }

                if (ent != null)
                {
                    Dictionary <string, string> props = new Dictionary <string, string>();
                    try
                    {
                        object comObj = ent.CreateInstanceAsObject(CLSCTX.CLSCTX_ALL);
                        if (comObj != null)
                        {
                            props.Add("CLSID", ent.Clsid.ToString("B"));
                            props.Add("Name", ent.Name);
                            props.Add("Server", ent.Server);

                            /* Need to implement a type library reader */
                            Type dispType = COMUtilities.GetDispatchTypeInfo(comObj);

                            await ent.LoadSupportedInterfacesAsync(false);

                            ObjectInformation view = new ObjectInformation(m_reg, ent.Name, comObj,
                                                                           props, ent.Interfaces.Select(i => m_reg.MapIidToInterface(i.Iid)).ToArray());
                            Program.GetMainForm().HostControl(view);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     try
     {
         IClassFactory factory = (IClassFactory)m_pObject;
         object        new_object;
         Guid          IID_IUnknown        = COMInterfaceEntry.IID_IUnknown;
         Dictionary <string, string> props = new Dictionary <string, string>();
         props.Add("Name", m_objName);
         factory.CreateInstance(null, ref IID_IUnknown, out new_object);
         ObjectInformation view = new ObjectInformation(m_registry, m_objName, new_object,
                                                        props, m_registry.GetInterfacesForObject(new_object));
         Program.GetMainForm().HostControl(view);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btnCreateInstance_Click(object sender, EventArgs e)
 {
     try
     {
         IClassFactory factory = (IClassFactory)_obj;
         object new_object;
         Guid IID_IUnknown = COMInterfaceEntry.IID_IUnknown;
         Dictionary<string, string> props = new Dictionary<string, string>();
         props.Add("Name", _name);
         factory.CreateInstance(null, ref IID_IUnknown, out new_object);
         ObjectInformation view = new ObjectInformation(_registry, _name, new_object,
             props, _registry.GetInterfacesForObject(new_object));
         Program.GetMainForm().HostControl(view);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 6
0
 private void btnCreate_Click(object sender, EventArgs e)
 {
     try
     {
         IElevatedFactoryServer factory = (IElevatedFactoryServer)_obj;
         COMCLSIDEntry          vso     = comboBoxClass.SelectedItem as COMCLSIDEntry;
         if (vso != null)
         {
             object new_object;
             Dictionary <string, string> props = new Dictionary <string, string>();
             props.Add("Name", _name);
             props.Add("CLSID", vso.Clsid.FormatGuid());
             factory.ServerCreateElevatedObject(vso.Clsid, COMInterfaceEntry.IID_IUnknown, out new_object);
             ObjectInformation view = new ObjectInformation(_registry, vso,
                                                            vso.Name, new_object,
                                                            props, _registry.GetInterfacesForObject(new_object));
             Program.GetMainForm(_registry).HostControl(view);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 7
0
        private void menuROTBindToObject_Click(object sender, EventArgs e)
        {
            if (listViewROT.SelectedItems.Count != 0)
            {
                MonikerInfo info = (MonikerInfo)(listViewROT.SelectedItems[0].Tag);

                Dictionary<string, string> props = new Dictionary<string, string>();
                props.Add("Display Name", info.strDisplayName);
                props.Add("CLSID", info.clsid.ToString("B"));

                try
                {
                    IBindCtx bindCtx = COMUtilities.CreateBindCtx(0);
                    Guid unk = COMInterfaceEntry.IID_IUnknown;
                    object comObj;
                    Type dispType;

                    info.moniker.BindToObject(bindCtx, null, ref unk, out comObj);
                    dispType = COMUtilities.GetDispatchTypeInfo(comObj);
                    ObjectInformation view = new ObjectInformation(info.strDisplayName, comObj, props, m_reg.GetInterfacesForObject(comObj));
                    Program.GetMainForm().HostControl(view);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 8
0
        private void menuViewCreateInstanceFromCLSID_Click(object sender, EventArgs e)
        {
            GetTextForm frm = new GetTextForm("");
            if (frm.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Guid g = new Guid(frm.Data);
                    Dictionary<string, string> props = new Dictionary<string,string>();
                    object comObj = null;
                    string strObjName = "";
                    COMInterfaceEntry[] ints = null;

                    if (m_comRegistry.Clsids.ContainsKey(g))
                    {
                        COMCLSIDEntry ent = m_comRegistry.Clsids[g];
                        strObjName = ent.Name;
                        props.Add("CLSID", ent.Clsid.ToString("B"));
                        props.Add("Name", ent.Name);
                        props.Add("Server", ent.Server);

                        comObj = ent.CreateInstanceAsObject();
                        ints = m_comRegistry.GetSupportedInterfaces(ent, false);
                    }
                    else
                    {
                        Guid unk = COMInterfaceEntry.IID_IUnknown;
                        IntPtr pObj;

                        if (COMUtilities.CoCreateInstance(ref g, IntPtr.Zero, COMUtilities.CLSCTX.CLSCTX_SERVER,
                            ref unk, out pObj) == 0)
                        {
                            ints = m_comRegistry.GetInterfacesForIUnknown(pObj);
                            comObj = Marshal.GetObjectForIUnknown(pObj);
                            strObjName = g.ToString("B");
                            props.Add("CLSID", g.ToString("B"));
                            Marshal.Release(pObj);
                        }
                    }

                    if (comObj != null)
                    {
                        /* Need to implement a type library reader */
                        Type dispType = COMUtilities.GetDispatchTypeInfo(comObj);

                        ObjectInformation view = new ObjectInformation(strObjName, comObj, props, ints);
                        view.ShowHint = DockState.Document;
                        view.Show(m_dockPanel);
                    }
                }
                catch(Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 9
0
        private async void createInstanceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = treeComRegistry.SelectedNode;

            if (node != null)
            {
                COMCLSIDEntry ent = null;
                if (node.Tag is COMCLSIDEntry)
                {
                    ent = (COMCLSIDEntry)node.Tag;
                }
                else if (node.Tag is COMProgIDEntry)
                {
                    ent = m_reg.MapClsidToEntry(((COMProgIDEntry)node.Tag).Clsid);
                }
                
                if(ent != null)
                {                    
                    Dictionary<string, string> props = new Dictionary<string,string>();
                    try
                    {
                        object comObj = ent.CreateInstanceAsObject(CLSCTX.CLSCTX_ALL);
                        if (comObj != null)
                        {                            
                            props.Add("CLSID", ent.Clsid.ToString("B"));
                            props.Add("Name", ent.Name);
                            props.Add("Server", ent.Server);
                            
                            /* Need to implement a type library reader */
                            Type dispType = COMUtilities.GetDispatchTypeInfo(comObj);

                            await ent.LoadSupportedInterfacesAsync(false);

                            ObjectInformation view = new ObjectInformation(m_reg, ent.Name, comObj, 
                                props, ent.Interfaces.Select(i => m_reg.MapIidToInterface(i.Iid)).ToArray());
                            Program.GetMainForm().HostControl(view);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }    
Ejemplo n.º 10
0
        private void createInstanceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = treeComRegistry.SelectedNode;

            if (node != null)
            {
                COMCLSIDEntry ent = null;
                if (node.Tag is COMCLSIDEntry)
                {
                    ent = (COMCLSIDEntry)node.Tag;
                }
                else if (node.Tag is COMProgIDEntry)
                {
                    ent = ((COMProgIDEntry)node.Tag).Entry;
                }

                if(ent != null)
                {
                    Dictionary<string, string> props = new Dictionary<string,string>();
                    try
                    {
                        object comObj = ent.CreateInstanceAsObject();
                        if (comObj != null)
                        {
                            props.Add("CLSID", ent.Clsid.ToString("B"));
                            props.Add("Name", ent.Name);
                            props.Add("Server", ent.Server);

                            /* Need to implement a type library reader */
                            Type dispType = COMUtilities.GetDispatchTypeInfo(comObj);

                            ObjectInformation view = new ObjectInformation(ent.Name, comObj, props, m_reg.GetSupportedInterfaces(ent, false));
                            view.ShowHint = DockState.Document;
                            view.Show(this.DockPanel);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }