1. Technology
Send to a Friend via Email
An Introduction to COM Programming with Delphi (6 / 6)
Page 1: Type Library: Cons/Pros
 More of this Feature
• Page 2: 5 steps to a Type Library
• Page 3: A Look Into the TLB Abyss
 More Delphi COM Lessons
• TOC
• Lesson 1
• Lesson 2
• Lesson 3
• Lesson 4
• Lesson 5
 Join the Discussion
"Post your views, comments, questions and doubts to this article."
Discuss!
 Related Resources
• COM / OLE / ActiveX programming with Delphi

Article written by Curtis Socha, brought to you by Zarko Gajic.

Welcome to the last lesson!

Type Libraries

Type libraries are a godsend to COM programmers. To illustrate why I believe this is so, let me explain what benefits you gain from using Type Libraries versus not using one.

Without Type Library:

  1. Your COM objects are only accessible from software written in C++ and Delphi.
  2. Your COM objects have no descriptions. Programmers must guess at what they do.
  3. If you write your COM Object in Delphi, C++ programmers must convert your interface definitions into C++ syntax so that they can use your COM Object.

With Type Library:

  1. You COM Objects will work with just about any compiler that can convert TLB files into native source code.
  2. Your COM Object has a description for each and every method, interface, and class it contains. This allows programmers to discern what your COM object does and how it functions.
  3. xxxxxx_TLB.Pas files take the place of the Globals.Pas I had you make in previous lessons. These files are automatically generated for you and contain the following guids:
    1. LIBID - Type Library ID
    2. CLASS - The guid of your COM object class. (a.k.a CLSID)
    3. DIID - DISPInterface ID (if applicable)
    4. IID - Non-DISPInterface (A normal interface is a non-DISPInterface).
  4. Automatic marshaling of parameters between COM clients and servers.
  5. You gain the serious advantage of early binding.
  6. You can use the Type Library editor to build your interface, classes, and methods for you.
As you can see, there are no benefits to be gained by not using one. That said, let me demonstrate how to make your first Type Library. This example will take up several pages because of the screen shots, but it’s a fairly simple and straightforward process. Let’s get started!

Next page > 5 steps to a Type Library > Page 1, 2, 3

An Introduction to COM Programming with Delphi: Navigator
<< Previous Lesson (5): Marshaling Data. Behold the power of Variant Arrays. Using Variants and Variant Arrays.

©2014 About.com. All rights reserved.