问题
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