Search code examples
delphidlldelphi-6typelib

Relationship between the auto-generated code in the _TLB and the DLL file it was generated from


I have a DLL which I am importing to the project as a type library using the Import Type Library functionality under Project in Delphi 6. I recently became curious about what the relationship between the _TLB.pas file and the DLL it was generated from are. Is the _TLB.pas file used in place of the library or only if I have my code interface with it? What other information would be good to know about how the code in the _TLB.pas works with the DLL it was generated from?


Solution

  • The .pas file is generated from the type library, which is typically contained within the COM DLL.

    The .pas file defines the interface to the COM DLL. COM DLL's which come with embedded type libraries have self-describing interfaces. You still need documentation to understand what the interfaces and methods do, and how the parameters are used. But you don't need to write the boiler plate interface code yourself.

    When a COM DLL has an embedded type library, you can create import units in your programming language of choice, not just Delphi.

    If you want to know COM there is no better reference than Don Box's Essential COM, one of the finest computing books I have ever read.