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