C#型OCX动态链接库

C#型OCX动态链接库,c#,com-interop,C#,Com Interop,如何从OCX或DLL中的方法和事件获取名称和描述? 下面的示例我可以从属性中获取它们。但是,我找不到方法和事件的 using System; using System.ComponentModel; using System.Reflection; public class getinfocom { public static void Main() { Type oComType = Type.GetTypeFromProgID("MSComctlLib.T

如何从OCX或DLL中的方法和事件获取名称和描述? 下面的示例我可以从属性中获取它们。但是,我找不到方法和事件的

using System;
using System.ComponentModel;
using System.Reflection;

public class getinfocom
{
    public static void Main()
    {

        Type oComType = Type.GetTypeFromProgID("MSComctlLib.TreeCtrl.2");
        dynamic oComInst = Activator.CreateInstance(oComType);

        Console.WriteLine("==========");
        Console.WriteLine("Properties");
        Console.WriteLine("==========");
        foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(oComInst))
        {
            Console.WriteLine(prop.DisplayName + " | " + prop.Description);
        }


        Console.WriteLine("==========");
        Console.WriteLine("Methods");
        Console.WriteLine("==========");

        foreach (MethodInfo method in oComType.GetMethods())
        {
            Console.WriteLine(method.Name + " | " + method.Attributes + " | ");
        }


        Console.WriteLine("==========");
        Console.WriteLine("Events");
        Console.WriteLine("==========");

        EventDescriptorCollection events = TypeDescriptor.GetEvents(oComType);

        foreach (EventDescriptor myEvent in events)
        {
            Console.WriteLine(myEvent.DisplayName + " | " + myEvent.Description);
        }


        Console.Read();
    }

}
我可以通过对象浏览器看到它们

您不能将DLL添加为COM引用,而直接使用interop访问控件吗?在我的机器上运行良好,尽管它触发了Visio 2013安装程序。啊。最好离这个遗留的COM组件远一点,它没有任何东西不是由.NET包装的,时间对它非常不友好,有太多的安全补丁。如果你想要一个TreeView,那就使用Winforms或WPF TreeView类吧。我只记得我从来都不能剥这个控件的皮,它是如何在我的屏幕上突出的(我当时正在使用Delphi,哈哈)。和微软差不多在同一时间对COM网格控件的处理是一样的。这只是一个例子。可能是另一个组成部分。我需要方法和事件的名称和描述。我只有他们的名字。请打电话,让作者修改他的类型库,以包含您要使用的[helpstring]属性。很有可能你会得到一个“你在开玩笑吗?使用手册!”的回答,但你在尝试之前不会知道。