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?
-
Is this the type library for the DLL from your other posts about the OleVariant? If so, I [suggested](http://stackoverflow.com/questions/5302768/convert-olevariant-to-object-in-delphi/5302974#5302974) you import the type library long ago. :) – Ken White Mar 15 '11 at 19:34
-
Yes. I'm trying to learn about how Delphi is working while I'm running this program and the imported type library to just better understand what I'm working with. – mnuzzo Mar 15 '11 at 19:36
-
the type library is the way you should have been working with this DLL all along instead of trying to typecast the OleVariant into a Delphi class (which it isn't). – Ken White Mar 15 '11 at 19:37
2 Answers
the _TLB.pas file is generated from the DLL; it is the Pascal based interface that your project will use to call functionality in the DLL.
At compile time you will need the _TLB.pas; at run-time you need the DLL.

- 601,492
- 42
- 1,072
- 1,490

- 23,965
- 9
- 74
- 154
-
From the FAQ: *Please don’t use signatures or taglines in your posts. Every post you make is already "signed" with your standard user card, which links directly back to your user page* You are approaching 10k, you should have got on top of that by now!! ;-) – David Heffernan Mar 15 '11 at 21:36
-
@David: Thanks, I completely missed that. Since I use this (very short --jeroen) signature everywhere, it is kind of in my autonomic nervous system. Will try to avoid it here in the future, but bear with me as I have to 'de-learn' my system :-) – Jeroen Wiert Pluimers Mar 15 '11 at 21:51
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.

- 601,492
- 42
- 1,072
- 1,490
-
Your answer to my last question seems to have disappeared. I'm not sure if you deleted it because it wasn't accepted yet, but I am trying to just learn more right now and I would have accepted if hooking had worked for me. – mnuzzo Mar 15 '11 at 19:40
-
@mnuzzo I deleted it because I'm not sure we have a clear enough picture of what you are doing. I'll undelete it if you wish. – David Heffernan Mar 15 '11 at 19:45
-
If you don't feel confident that it's appropriate yet, then that's ok with me. This is my first time working with Delphi and DLL files so I'm not going to pretend that there's no possible other solution or that what I may be doing is the right way to go about it. All I know is the code that's in front of me, the error that's being caused and what I can see from the DLL files. – mnuzzo Mar 15 '11 at 19:54