编程语言
首页 > 编程语言> > C#调用ActiveX ClsID, COM ProgID, Runtime Type动态创建对象

C#调用ActiveX ClsID, COM ProgID, Runtime Type动态创建对象

作者:互联网

//兼容老旧系统的方法。反射之外的选择
object objClsID = Activator.CreateInstance(Type.GetTypeFromCLSID(Guid.Parse("ClsID")));  //ActiveX
object objProgID = Activator.CreateInstance(Type.GetTypeFromProgID("ProgID"));       //COM
object objType = Activator.CreateInstance(Type.GetTypeFromHandle(this.GetType().TypeHandle)); // RuntimeType.New Instance   

//调用方法
objClsID.GetType().InvokeMember(...); 
objClsID.GetType().GetMethod("").Invoke(...);

 

标签:GetType,object,ActiveX,C#,objClsID,CreateInstance,Activator,Type
来源: https://www.cnblogs.com/leavind/p/16177588.html