예제 #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).ToArray());
                    EntryPoint.GetMainForm(m_registry).HostControl(view);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #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);
        }
예제 #3
0
 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, _entry, _name, new_object,
                                                        props, _registry.GetInterfacesForObject(new_object).ToArray());
         EntryPoint.GetMainForm(_registry).HostControl(view);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #4
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).ToArray());
             EntryPoint.GetMainForm(_registry).HostControl(view);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }