Link to home
Start Free TrialLog in
Avatar of Wim ten Brink
Wim ten BrinkFlag for Netherlands

asked on

[Type libraries] How to open them and...

...no, not in Delphi. But in my own application. I need to open a .DLL, .EXE or .TLB file to analyze the type library so I can report all objects, types, methods, parameters, bicycles, properties and whatever else I can find inside it. It must be done in Delphi code and Delphi code only. I can use the Windows API and whatever a fresh W2K installation straight out of the box has available, but nothing more. No additional ActiveX controls and no Delphi components. The application is a console application so any VCL thingie is too much.

So, how to open a type library, read the contents and report it? Anyone here with some valuable clues?
Avatar of robert_marquardt
robert_marquardt

I think the .TLB is simply stored as a resource in the EXE or DLL so either simply read the .TLB or get the resource from the EXE or DLL.
From there on it is interpretation of the binary data therein.
I doubt that this is an easy task because Borland rewrites that part of the IDE for each Delphi version.

BTW you can use non-visual components in a console application. You only have to create and destroy them explicitly.
Avatar of Wim ten Brink

ASKER

Sorry, I found what I have been looking for... ;-)

http://www.howtodothings.com/showarticle.asp?article=302 is a very interesting page about type libraries. It's not simple but it does work. It's just a near-disaster to learn to use it all...
Oh, well... I'm an expert. Have to work now to become a better expert... :-)

And for those looking for a solution: look at the API "LoadTypeLib" and the ITypeLib, ITypeLib2, ITypeInfo, ITypeInfo2 and other interfaces for more help. Be aware that this is a very complex thing, btw.

If you are interested in source for FULL exploration of type library information, and don't mind waiting a few hours, I can post source I wrote for a type library explorer. The source unit will let you walk CoClasses, Interfaces, Enumeration, Records, Aliases, functions, parameters for functions, etc.. basically everything that a type library viewer would display to you.

The classes are TObject based, and the unit requires only Windows, SysUtils, Classes, Contnrs (for TObjectList), ActiveX and ComObj. It has also been optimized so that loading of sub item objects is done on demand (instead of all at once).

Let me know if you are interested

Regards,
Russell

I'm not to sure about what method you want to use. . . but if you look on the Delphi IDE "Project"  Menu and Click the "Import Type Library" menu Item, you will get the "Import Type Library" wizard. . . which will list the "Registered" type librarys on your machine, you will get a List of the names of the Type Librarys, and you can Highlight the one you need an click "Install" at the bottom. . . this will create the  _TLP.pas for that in the "Imports" folder of your Delphi Foilder, and most likly add something new to your activeX VCL tab. . . if the DLL is not on the list you can click the "Add" button and do a file search for the DLL you want to use. . .
@rllibby: even if Workshop_Alex isn't, I would be :-)
ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
WOW! Someone has been very busy typing last night, I see...

Okay, okay... You get the points and the A Grade. Quite a useful unit, I think... :-) Well done...
Would be nice, though, if you could also answer https://www.experts-exchange.com/questions/20775617/COM-Get-and-Set-methods-for-a-property.html for another 500 pts and an A grade... ;-)