Dynamic link library or DLL is a collection of routines (i.e. small programs) that can be called by other applications and DLLs.
Dynamic link libraries or DLLs are pieces of sharable codes that various other applications can use. These DLLs contain common code that may be required by different applications to perform similar operations. Thus allowing a single copy of routines to be used by many applications at the same time.
Another advantage of DLLs is that we can safely use routines created in other development environments like VB, C++ to be used in delphi or vice-versa.
Now you must be thinking as how to create a DLL in delphi. Is it really difficult or is it simple?
Well dear developer no need to worry. Its pretty simple in delphi.
Here I will try to create a simple delphi application using a new DLL -
This example will try to do the following for us -
First we will create a DLL that will have methods in it -
- First will be a procedure and will display a welcome message.
- Second procedure will display a message dialog and will tell us when summation of numbers will start.
- Third procedure will also display a message dialog and will tell us when the summation is over and finally,
- Fourth will be a function and will actually do summation of two numbers for us and return the result back to our calling program.
So all set in our mind then lets create our DLL now ->
First open Delphi and select File -> New -> DLL to create a DLL template for us. Then add Dialogs unit to uses portion of the DLL in case it is not already present (This is because I want to show a dialog box in our DLL to highlight the progress). Now, Save the project as MyLibrary.
Well thats not all done, we have to do some more...