Hello everybody,
Anyone knows if there is any Delphi component or library that I could get all the classes, properties and types of an Com Object (something like a parser).
i want to programmatically enumerate classes, properties and types.
Bye.
Hello everybody,
Anyone knows if there is any Delphi component or library that I could get all the classes, properties and types of an Com Object (something like a parser).
i want to programmatically enumerate classes, properties and types.
Bye.
Well, COM objects are referenced through interfaces, which are opaque abstractions by design. You can't get at the underlying object without some black magic that will only work if you have a really good knowledge of the low-level details of the Delphi object model and the object was actually written in Delphi.
About the best you can do is examine the interface declaration itself, which will give you all the available information in its methods and properties.
You need to be more specific. There are two ways to interpret your question.
One is that you have a COM component (e.g. some library), and you want to programmatically enumerate interfaces/properties/methods of that. Usually (but not always), COM components come with a type library that contains full metainformation about all this - it's either embedded into the COM .exe or .dll, or is a separate .tlb file. In any case, if the COM component is properly registered in the system (e.g. using regsvr32), then COM provides a standard API to retrieve that type information, centered around ITypeLib and ITypeInfo interfaces.
Another interpretation is that you get a reference to a particular COM object, and you need to enumerate all methods/properties on that and/or invoke them by computed name, like Java or C# reflection, or Delphi RTTI. If so, then it is only possible if the COM object implements IDispatch interface, which allows you to do all of the above.
You can get at everything you want from the registry, however this will take some time as the information is not ordered in such a way to give you the information you want without first analyzing most of it. If you download the utility OLEVIEW32 from the Microsoft platform SDK (available on MSDN) you can use it to explore the COM interfaces registered on the machine.
The fundamentals of COM work through the interfaces registered in the registry, under the HKEY CLASSES ROOT\CLSID. When you ask for a specific com object, it resolves to one of these guids, which in turn looks at the InprocServer32 section under this guid to determine what DLL/EXE to load, and what threading model to use. You could use this information to build a map of guids which also resolve to the same DLL (this is to get the classes)
In HKEY CLASSES ROOT\Interface is a link to all of the interfaces registered in the system. Again, its time to play lookup since much of this information is just pointers to another key, or type library. What IS here however and is useful is a list of GUID -> InterfaceName (default property of each guid).
In HKEY CLASSES ROOT\TypeLib is a link to all of the type libraries registered in the system.