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);
}
}
}
}