Find all properties of an ActiveX component

一世执手 提交于 2020-01-14 10:28:32

问题


I tried looking around but was not able to convince myself with an answer as the world of COM/ActiveX seems to be very confusing.
Basically what I want to know is, given the GUID, is there a way to know all the interfaces, properties and methods exposed by an ActiveX control? I read somewhere that you just have to ask if a particular property is there or not. But how do I ask about a property before knowing what are there?
I guess IDispatch does something similar, but I am not able to make out how to use it. If this is the one that works, a small snippet, preferably in C# would help me understand better.

Thanks


回答1:


You can use PowerShell for this:

$a = new-object -comobject ProgId
#get properties
$a | Get-Member -membertype properties 
#or get all members
$a | Get-Member

And in C# you can use Type.GetMembers Method.




回答2:


ActiveX controls don't have to be self-descriptive and be capable to enumerate supported interfaces and/or properties. As other COM classes they implement certain interfaces and being implementing a certain set of mandatory interfaces they are good for embedding into host application. That is, you might end up being unable to find properties for a certain valid ActiveX Control.

Quite so often though, you can succeed with this tasks if given control does what most of controls do. Control's COM Class typically has a typelibrary you can discover by looking at registry reference, or IProvideClassInfo interface. From there on when you hold ITypeInfo interface, you can locate IDispatch derived interfaces of the class, and then enumerate properties and method using the type library, which holds this information.




回答3:


You can use the OLE/COM Object Viewer in Microsoft's Resource Toolkit. That will list all properties/methods/events/etc.



来源:https://stackoverflow.com/questions/14411255/find-all-properties-of-an-activex-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!