C#类型OCX DLL

时间:2016-03-05 02:16:22

标签: c# com-interop

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

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

}

我可以通过对象浏览器看到它们 enter image description here

0 个答案:

没有答案