OleViewDotNet.ROTViewer.menuROTBindToObject_Click C# (CSharp) Method

menuROTBindToObject_Click() private method

private menuROTBindToObject_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        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(m_reg, info.strDisplayName, comObj, props, m_reg.GetInterfacesForObject(comObj));
                    Program.GetMainForm().HostControl(view);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }