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); } } }
public async Task OpenObjectInformation(object comObj, string defaultName) { if (comObj != null) { COMCLSIDEntry ent = null; Dictionary <string, string> props = new Dictionary <string, string>(); string strObjName = ""; IEnumerable <COMInterfaceEntry> ints = null; Guid clsid = COMUtilities.GetObjectClass(comObj); if (m_registry.Clsids.ContainsKey(clsid)) { ent = m_registry.Clsids[clsid]; strObjName = ent.Name; props.Add("CLSID", ent.Clsid.FormatGuid()); props.Add("Name", ent.Name); props.Add("Server", ent.DefaultServer); await ent.LoadSupportedInterfacesAsync(false, null); ints = ent.Interfaces.Select(i => m_registry.MapIidToInterface(i.Iid)); } else { ints = m_registry.GetInterfacesForObject(comObj).ToArray(); strObjName = defaultName != null ? defaultName : clsid.FormatGuid(); props.Add("CLSID", clsid.FormatGuid()); } Type dispType = COMUtilities.GetDispatchTypeInfo(this, comObj); HostControl(new ObjectInformation(m_registry, ent, strObjName, comObj, props, ints.ToArray())); } }
private COMInterfaceEntry[] GetInterfaces() { if (_interfaces == null) { _interfaces = _registry.GetInterfacesForObject(_target).OrderBy(i => i.Name).ToArray(); } return(_interfaces); }
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); } }
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); } }