Creating and Using DLLs

The following sections take you through the process of actually creating a DLL with Delphi. You'll see how to create an interface unit so that you can make your DLLs available to other programs. You'll also learn how to incorporate Delphi forms into DLLs before going on to using DLLs in Delphi.

Counting Your Pennies (A Simple DLL)

The following DLL example illustrates placing a routine that's a favorite of many computer science professors into a DLL. The routine converts a monetary amount in pennies to the minimum number of nickels, dimes, or quarters needed to match the total number of pennies.

A Basic DLL

The library contains the PenniesToCoins() method. Listing 6.1 shows the complete DLL project.

Listing 6.1. PenniesLib.dpr ...

Get Borland® Delphi™ 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.